Docker end-user images #1084
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: Docker end-user images | |
# Builds all end-user images nightly. | |
# | |
# Can also be triggered manually via GitHub interface using specific | |
# git refs and tag prefix for e.g. releases. | |
on: | |
schedule: | |
# '*' is a special character in YAML, so string must be quoted | |
- cron: "0 1 * * *" | |
workflow_dispatch: | |
inputs: | |
tag_prefix: | |
description: "tag prefix for docker images" | |
default: "nightly" | |
type: string | |
required: true | |
baseimage: | |
description: "base image" | |
default: "docker.io/dolfinx/dev-env:current" | |
type: string | |
required: true | |
dockerfile: | |
description: "Dockerfile" | |
default: "docker/Dockerfile.end-user" | |
type: string | |
required: true | |
dolfinx_ref: | |
description: "dolfinx git ref to checkout" | |
default: "main" | |
type: string | |
required: true | |
basix_ref: | |
description: "basix git ref to checkout" | |
default: "main" | |
type: string | |
required: true | |
ufl_ref: | |
description: "ufl git ref to checkout" | |
default: "main" | |
type: string | |
required: true | |
ffcx_ref: | |
description: "ffcx git ref to checkout" | |
default: "main" | |
type: string | |
required: true | |
jobs: | |
create_end_user_images: | |
name: Build DOLFINx end-user images | |
if: ${{ github.repository == 'FEniCS/dolfinx' }} | |
strategy: | |
matrix: | |
include: | |
- arch_tag: amd64 | |
os: ubuntu-latest | |
- arch_tag: arm64 | |
os: buildjet-8vcpu-ubuntu-2204-arm | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Create tag without image name | |
run: | | |
USER_INPUT=${{ github.event.inputs.tag_prefix }} | |
echo "TAG_PREFIX=${USER_INPUT:-nightly}" >> $GITHUB_ENV | |
echo "TAG=${USER_INPUT:-nightly}-${{ matrix.arch_tag }}" >> $GITHUB_ENV | |
- name: Get git refs | |
run: | | |
USER_INPUT=${{ github.event.inputs.dolfinx_ref }} | |
echo "DOLFINX_REF=${USER_INPUT:-main}" >> $GITHUB_ENV | |
USER_INPUT=${{ github.event.inputs.basix_ref }} | |
echo "BASIX_REF=${USER_INPUT:-main}" >> $GITHUB_ENV | |
USER_INPUT=${{ github.event.inputs.ufl_ref }} | |
echo "UFL_REF=${USER_INPUT:-main}" >> $GITHUB_ENV | |
USER_INPUT=${{ github.event.inputs.ffcx_ref }} | |
echo "FFCX_REF=${USER_INPUT:-main}" >> $GITHUB_ENV | |
- name: Set Dockerfile | |
run: | | |
USER_INPUT=${{ github.event.inputs.dockerfile }} | |
echo "DOCKERFILE=${USER_INPUT:-docker/Dockerfile.end-user}" >> $GITHUB_ENV | |
- name: Set baseimage | |
run: | | |
USER_INPUT=${{ github.event.inputs.baseimage }} | |
echo "BASEIMAGE=${USER_INPUT:-ghcr.io/fenics/dolfinx/dev-env:current}" >> $GITHUB_ENV | |
- name: Checkout basix | |
uses: actions/checkout@v4 | |
with: | |
repository: "FEniCS/basix" | |
path: "basix" | |
ref: ${{ env.BASIX_REF }} | |
- name: Checkout UFL | |
uses: actions/checkout@v4 | |
with: | |
repository: "FEniCS/ufl" | |
path: "ufl" | |
ref: ${{ env.UFL_REF }} | |
- name: Checkout FFCx | |
uses: actions/checkout@v4 | |
with: | |
repository: "FEniCS/ffcx" | |
path: "ffcx" | |
ref: ${{ env.FFCX_REF }} | |
- name: Checkout DOLFINx | |
uses: actions/checkout@v4 | |
with: | |
repository: "FEniCS/dolfinx" | |
path: "dolfinx" | |
ref: ${{ env.DOLFINX_REF }} | |
- name: Set default FFCx options | |
run: | | |
echo '{ }' > dolfinx/docker/ffcx_options.json | |
- name: Set default DOLFINx JIT options | |
run: | | |
echo '{ "cffi_extra_compile_args" : ["-O2"] } ' > dolfinx/docker/dolfinx_jit_options.json | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build dolfinx-onbuild | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
DOLFINX_CMAKE_BUILD_TYPE=RelWithDebInfo | |
BASEIMAGE=${{ env.BASEIMAGE }} | |
context: . | |
file: dolfinx/${{ env.DOCKERFILE }} | |
load: true | |
target: dolfinx-onbuild | |
tags: docker.io/dolfinx/dolfinx-onbuild:${{ env.TAG }} | |
- name: Build intermediate | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
DOLFINX_CMAKE_BUILD_TYPE=RelWithDebInfo | |
BASEIMAGE=${{ env.BASEIMAGE }} | |
context: . | |
file: dolfinx/${{ env.DOCKERFILE }} | |
target: intermediate | |
- name: Build dolfinx | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
BASEIMAGE=${{ env.BASEIMAGE }} | |
context: . | |
file: dolfinx/${{ env.DOCKERFILE }} | |
load: true | |
target: dolfinx | |
tags: docker.io/dolfinx/dolfinx:${{ env.TAG }} | |
- name: Build lab | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
BASEIMAGE=${{ env.BASEIMAGE }} | |
context: . | |
file: dolfinx/${{ env.DOCKERFILE }} | |
load: true | |
target: lab | |
tags: docker.io/dolfinx/lab:${{ env.TAG }} | |
- name: Run basic tests inside container | |
if: ${{ !contains(github.event.inputs.dockerfile, 'dummy') }} | |
run: | | |
docker run --rm docker.io/dolfinx/dolfinx:${{ env.TAG }} \ | |
python3 -c "import dolfinx; from dolfinx.fem import functionspace; from dolfinx.mesh import create_unit_square; from mpi4py import MPI; mesh = create_unit_square(MPI.COMM_WORLD, 10, 10); V = functionspace(mesh, ('Lagrange', 1));" | |
docker run --rm docker.io/dolfinx/dolfinx:${{ env.TAG }} \ | |
/bin/bash -c "source /usr/local/bin/dolfinx-complex-mode && python3 -c $'import dolfinx; from dolfinx.fem import functionspace; from dolfinx.mesh import create_unit_square; from mpi4py import MPI; mesh = create_unit_square(MPI.COMM_WORLD, 10, 10); V = functionspace(mesh, (\"Lagrange\", 1));'" | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push to the DockerHub registry | |
run: | | |
docker push docker.io/dolfinx/dolfinx-onbuild:${{ env.TAG }} | |
docker push docker.io/dolfinx/dolfinx:${{ env.TAG }} | |
docker push docker.io/dolfinx/lab:${{ env.TAG }} | |
- name: Cleanup | |
run: | | |
docker rmi docker.io/dolfinx/lab:${{ env.TAG }} | |
docker rmi docker.io/dolfinx/dolfinx:${{ env.TAG }} | |
docker rmi docker.io/dolfinx/dolfinx-onbuild:${{ env.TAG }} | |
create_multiarch_end_user_images: | |
name: Create multiarch end-user images | |
if: ${{ github.repository == 'FEniCS/dolfinx' }} | |
runs-on: ubuntu-latest | |
needs: | |
- create_end_user_images | |
steps: | |
- name: Get tag name | |
id: tag_name | |
run: | | |
USER_INPUT=${{ github.event.inputs.tag_prefix }} | |
echo "TAG=${USER_INPUT:-nightly}" >> $GITHUB_ENV | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push multiarch images to ghcr.io and docker.io | |
run: | | |
GH_PREFIX="ghcr.io/fenics/dolfinx" | |
DH_PREFIX="docker.io/dolfinx" | |
docker buildx imagetools create \ | |
--tag ${DH_PREFIX}/dolfinx-onbuild:${{ env.TAG }} \ | |
--tag ${GH_PREFIX}/dolfinx-onbuild:${{ env.TAG }} \ | |
${DH_PREFIX}/dolfinx-onbuild:${{ env.TAG }}-amd64 \ | |
${DH_PREFIX}/dolfinx-onbuild:${{ env.TAG }}-arm64 | |
docker buildx imagetools create \ | |
--tag ${DH_PREFIX}/dolfinx:${{ env.TAG }} \ | |
--tag ${GH_PREFIX}/dolfinx:${{ env.TAG }} \ | |
${DH_PREFIX}/dolfinx:${{ env.TAG }}-amd64 \ | |
${DH_PREFIX}/dolfinx:${{ env.TAG }}-arm64 | |
docker buildx imagetools create \ | |
--tag ${DH_PREFIX}/lab:${{ env.TAG }} \ | |
--tag ${GH_PREFIX}/lab:${{ env.TAG }} \ | |
${DH_PREFIX}/lab:${{ env.TAG }}-amd64 \ | |
${DH_PREFIX}/lab:${{ env.TAG }}-arm64 |