-
Notifications
You must be signed in to change notification settings - Fork 14
249 lines (225 loc) · 8.48 KB
/
build-container.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
246
247
248
249
name: Build and test container images
on:
push:
pull_request:
repository_dispatch:
types:
- dispatch-build
workflow_dispatch:
jobs:
build-images:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# os: ['el9', 'cuda_11_8_0']
os: ['el9']
osg_series: ['23']
repo: ['development', 'testing', 'release']
# platform: ['linux/amd64']
platform: ['linux/amd64','linux/arm64']
exclude:
# cuda builds take a super long time; only do one of them
- os: cuda_11_8_0
repo: development
- os: cuda_11_8_0
repo: testing
steps:
- uses: actions/checkout@v3
- id: custom-image-name
env:
SERIES: ${{ matrix.osg_series }}
REPO: ${{ matrix.repo }}
OS: ${{ matrix.os }}
run: |
PREFIX="output_image=${GITHUB_REPOSITORY}:${SERIES}"
echo "${PREFIX}-${OS}-${REPO}" >> ${GITHUB_OUTPUT}
echo "base_tag=${SERIES}-${OS}-${REPO}" >> ${GITHUB_OUTPUT}
- id: slash-escape
run: |
platform=${{ matrix.platform }}
echo "platform=${platform//\//-}" >> ${GITHUB_OUTPUT}
- name: Harbor login
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
uses: docker/login-action@v2
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
- id: build-image
uses: ./.github/actions/build-container-local
with:
registry_url: hub.opensciencegrid.org
osg_series: ${{ matrix.osg_series }}
osg_repo: ${{ matrix.repo }}
base_os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
output_image: ${{ steps.custom-image-name.outputs.output_image }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build-image.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
- name: Export tags
run: |
mkdir -p /tmp/tags
echo ${{ steps.build-image.outputs.image-list }} > /tmp/tags/${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
- name: Upload tags
uses: actions/upload-artifact@v4
with:
name: tags-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/tags/*
if-no-files-found: error
retention-days: 1
- name: Prepare CVMFS
if: ${{ matrix.platform == 'linux/amd64' }}
run: |
sudo ./tests/setup_cvmfs.sh
- name: Docker + CVMFS bindmount
if: ${{ matrix.platform == 'linux/amd64' }}
id: test-docker-cvmfs
env:
CONTAINER_IMAGE: ${{ steps.build-image.outputs.base_image }}@${{ steps.build-image.outputs.digest }}
run: |
sudo ./tests/test_inside_gha.sh docker \
bindmount \
"$CONTAINER_IMAGE"
- name: Docker + cvmfsexec
if: ${{ matrix.platform == 'linux/amd64' }}
id: test-docker-cvmfsexec
env:
CONTAINER_IMAGE: ${{ steps.build-image.outputs.base_image }}@${{ steps.build-image.outputs.digest }}
run: |
sudo ./tests/test_inside_gha.sh docker \
cvmfsexec \
"$CONTAINER_IMAGE"
# - name: Singularity + CVMFS bindmount
# if: ${{ matrix.platform == 'linux/amd64' }}
# id: test-singularity-cvmfs
# env:
# CONTAINER_IMAGE: ${{ steps.build-image.outputs.base_image }}@${{ steps.build-image.outputs.digest }}
# run: |
# if [[ $CONTAINER_IMAGE == *cuda* ]]; then
# echo >&2 "Skipping test: \$APPTAINER_TMPDIR (${APPTAINER_TMPDIR:-/tmp}) too small for cuda-based images"
# exit 0
# else
# sudo ./tests/test_inside_gha.sh singularity \
# bindmount \
# "$CONTAINER_IMAGE"
# fi
# - name: Harbor login
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
# uses: docker/login-action@v2
# with:
# registry: hub.opensciencegrid.org
# username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
# password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
# - name: Docker login
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
# uses: docker/login-action@v2
# with:
# registry: docker.io
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Push to OSG Harbor
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
# env:
# IMAGE_LIST: ${{ steps.build-image.outputs.image-list}}
# OSG_SERIES: ${{ matrix.osg_series }}
# run: |
# case $OSG_SERIES in
# '23' ) DEFAULT_OS=el9 ;;
# * ) exit ;;
# esac
# for registry in hub.opensciencegrid.org docker.io; do
# for image in ${IMAGE_LIST}; do
# fqin=${registry}/${image}
# docker tag ${image} ${fqin}
# docker push ${fqin}
# # Also tag the image for the default OS as the OS-less tag
# # (i.e. 23-el9-release -> 23-release)
# image2=${image/-${DEFAULT_OS}-/-} # bash syntax for search-and-replace
# if [[ $image2 != $image ]]; then
# fqin2=${registry}/${image2}
# docker tag ${image} ${fqin2}
# docker push ${fqin2}
# fi
# done
# done
merge-manifests:
runs-on: ubuntu-latest
needs:
- build-images
strategy:
fail-fast: false
matrix:
# os: ['el9', 'cuda_11_8_0']
os: ['el9']
osg_series: ['23']
repo: ['development', 'testing', 'release']
exclude:
# cuda builds take a super long time; only do one of them
- os: cuda_11_8_0
repo: development
- os: cuda_11_8_0
repo: testing
steps:
- id: base-tag
env:
SERIES: ${{ matrix.osg_series }}
REPO: ${{ matrix.repo }}
OS: ${{ matrix.os }}
run: |
echo "base_tag=${SERIES}-${OS}-${REPO}" >> ${GITHUB_OUTPUT}
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-${{ steps.base-tag.outputs.base_tag }}-*
merge-multiple: true
- name: Download tags
uses: actions/download-artifact@v4
with:
path: /tmp/tags
pattern: tags-${{ steps.base-tag.outputs.base_tag }}-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Harbor login
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
uses: docker/login-action@v2
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
- name: Merge Artifacts
working-directory: /tmp
run: |
BASE_IMG=hub.opensciencegrid.org/opensciencegrid/osgvo-docker-pilot
DIGESTS=$(for digest in $(ls digests/); do echo $BASE_IMG@sha256:$digest; done)
TAGS=$(cat tags/*-amd64)
for tag in ${TAGS//,/ }; do
docker buildx imagetools create --tag $tag $DIGESTS;
done