-
Notifications
You must be signed in to change notification settings - Fork 18
181 lines (181 loc) · 6.26 KB
/
docker.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
name: docker
on:
pull_request:
branches: [master]
paths-ignore:
- '**.md'
- 'VirtualBox/**'
- '.github/workflows/c-cpp.yml'
- 'CITATION.cff'
- '.mailmap'
push:
branches: [master]
tags: ['v**']
paths-ignore:
- '**.md'
- 'VirtualBox/**'
- '.github/workflows/c-cpp.yml'
- 'CITATION.cff'
- '.mailmap'
schedule: [{cron: '37 13 * * SUN'}] # Sunday at 13:37
defaults: {run: {shell: 'bash -el {0}'}}
jobs:
build:
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
strategy:
matrix:
type: [gpu, cpu]
permissions: {contents: read, packages: write}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.ref }} # fix SHA
- uses: docker/metadata-action@v5
id: meta
with:
images: |
synerbi/sirf
ghcr.io/synerbi/sirf
flavor: |
latest=auto
suffix=${{ matrix.type == 'gpu' && '-gpu,onlatest=true' || '' }}
tags: |
type=edge
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.licenses=Apache-2.0${{ matrix.type == 'gpu' && ' AND BSD-3-Clause AND GPL-3.0' || '' }}
- uses: docker/login-action@v3
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
with:
username: ${{ secrets.DOCKER_USR }}
password: ${{ secrets.DOCKER_PWD }}
- uses: jlumbroso/[email protected]
with:
docker-images: false
large-packages: false
- name: cache
uses: actions/cache@v4
with:
key: ccache-docker-${{ matrix.type }}-${{ github.ref_name }}-${{ github.run_id }}
restore-keys: |
ccache-docker-${{ matrix.type }}-${{ github.ref_name }}
ccache-docker-${{ matrix.type }}
ccache-docker
ccache
path: docker/devel/.ccache
- id: pull
name: pull
run: |
suffix=${{ matrix.type == 'gpu' && '-gpu' || '' }}
# pull core image
core_image=ghcr.io/synerbi/sirf:core$suffix
docker pull $core_image || :
# pull sirf image
docker pull ghcr.io/synerbi/sirf:${{ fromJSON(steps.meta.outputs.json).tags[0] }} || :
echo "suffix=$suffix" >> "$GITHUB_OUTPUT"
echo "core_image=$core_image" >> "$GITHUB_OUTPUT"
- id: build
name: build
run: |
# rebuild sirf image
./docker/compose.sh -bR${{ matrix.type == 'gpu' && 'g' || 'c' }} -- --build-arg BUILD_CIL=ON
image=synerbi/sirf:latest${{ steps.pull.outputs.suffix }}
echo "image=$image" >> "$GITHUB_OUTPUT"
# tag potentially newer core image
docker tag synerbi/jupyter:scipy-${{ matrix.type }} ${{ steps.pull.outputs.core_image }}
# make a dummy Dockerfile to use with build-push-action
context=$(mktemp -d)
echo "FROM $image" >> "$context/Dockerfile"
echo "context=$context" >> "$GITHUB_OUTPUT"
- name: test CIL
run: >
docker run --rm -v ./.github/workflows:/gh --user $(id -u) --group-add users
${{ steps.build.outputs.image }} /gh/test_cil.sh
- uses: docker/build-push-action@v5
with:
context: ${{ steps.build.outputs.context }}
push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- if: github.ref == 'refs/heads/master'
name: push core image
run: docker push ${{ steps.pull.outputs.core_image }}
devel:
if: github.event_name == 'schedule' || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
strategy:
matrix:
type: [gpu, cpu]
permissions: {contents: read, packages: write}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.ref }} # fix SHA
- uses: docker/metadata-action@v5
id: meta
with:
images: |
synerbi/sirf
ghcr.io/synerbi/sirf
flavor: |
latest=false
suffix=${{ matrix.type == 'gpu' && '-gpu,onlatest=true' || '' }}
tags: devel
labels: |
org.opencontainers.image.licenses=Apache-2.0${{ matrix.type == 'gpu' && ' AND BSD-3-Clause AND GPL-3.0' || '' }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USR }}
password: ${{ secrets.DOCKER_PWD }}
- uses: jlumbroso/[email protected]
with:
docker-images: false
large-packages: false
- name: cache
uses: actions/cache@v4
with:
key: ccache-docker-${{ matrix.type }}-${{ github.ref_name }}-${{ github.run_id }}
restore-keys: |
ccache-docker-${{ matrix.type }}-${{ github.ref_name }}
ccache-docker-${{ matrix.type }}
ccache-docker
ccache
path: docker/devel/.ccache
- id: pull
name: pull
run: |
suffix=${{ matrix.type == 'gpu' && '-gpu' || '' }}
# pull core image
core_image=ghcr.io/synerbi/sirf:core$suffix
docker pull $core_image || :
# pull sirf image
docker pull ghcr.io/synerbi/sirf:${{ fromJSON(steps.meta.outputs.json).tags[0] }} || :
echo "suffix=$suffix" >> "$GITHUB_OUTPUT"
echo "core_image=$core_image" >> "$GITHUB_OUTPUT"
- id: build
name: build
run: |
# rebuild sirf image
./docker/compose.sh -dbR${{ matrix.type == 'gpu' && 'g' || 'c' }}
image=synerbi/sirf:devel${{ steps.pull.outputs.suffix }}
echo "image=$image" >> "$GITHUB_OUTPUT"
- name: test CIL
run: >
docker run --rm -v ./.github/workflows:/gh --user $(id -u) --group-add users
${{ steps.build.outputs.image }} /gh/test_cil.sh