Skip to content

Multi-architecture Docker images and parallel builds #12

Multi-architecture Docker images and parallel builds

Multi-architecture Docker images and parallel builds #12

Workflow file for this run

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