Multi-architecture Docker images and parallel builds #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push Docker images to Docker Hub | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- develop | |
# temporary | |
pull_request: | |
jobs: | |
build_docker_images: | |
# This workflow is only of value to PyBaMM and would always be skipped in forks | |
# if: github.repository_owner == 'pybamm-team' | |
name: Build image (${{ matrix.build-args }}) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
build-args: ["", "JAX=true", "ODES=true", "IDAKLU=true", "ALL=true"] | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Create tags for Docker images based on build-time arguments | |
id: tags | |
run: | | |
if [ "${{ matrix.build-args }}" = "" ]; then | |
echo "tag=latest" >> "$GITHUB_OUTPUT" | |
elif [ "${{ matrix.build-args }}" = "JAX=true" ]; then | |
echo "tag=jax" >> "$GITHUB_OUTPUT" | |
elif [ "${{ matrix.build-args }}" = "ODES=true" ]; then | |
echo "tag=odes" >> "$GITHUB_OUTPUT" | |
elif [ "${{ matrix.build-args }}" = "IDAKLU=true" ]; then | |
echo "tag=idaklu" >> "$GITHUB_OUTPUT" | |
elif [ "${{ matrix.build-args }}" = "ALL=true" ]; then | |
echo "tag=all" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Build and push Docker image to Docker Hub | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: scripts/Dockerfile | |
tags: pybamm/pybamm:${{ steps.tags.outputs.tag }} | |
push: false # temporary | |
build-args: ${{ matrix.build-args }} | |
platforms: linux/amd64, linux/arm64 | |
- name: List built image(s) | |
run: docker images |