-
-
Notifications
You must be signed in to change notification settings - Fork 182
245 lines (219 loc) · 8.29 KB
/
docker-end-user.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
---
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