-
Notifications
You must be signed in to change notification settings - Fork 14
/
docker-ros.yml
425 lines (394 loc) · 16.5 KB
/
docker-ros.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline" # run child pipeline if triggered by parent pipeline
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # run merge request pipeline if triggered by merge request
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS # don't run branch pipeline if open merge request exists
when: never
- if: $CI_COMMIT_BRANCH # run branch pipeline if triggered by commit
- if: $CI_COMMIT_TAG # run tag pipeline with specific image tags if triggered by tag
variables:
TARGET: run # Target stage of Dockerfile (comma-separated list) [dev|run]
PLATFORM: amd64 # Target platform architecture (comma-separated list) [amd64|arm64|...]
BASE_IMAGE: '' # Base image name:tag (required)
COMMAND: '' # Launch command of run image (required if target=run)
IMAGE_NAME: ${CI_REGISTRY_IMAGE} # Image name of run image
IMAGE_TAG: latest # Image tag of run image
DEV_IMAGE_NAME: ${IMAGE_NAME} # Image name of dev image
DEV_IMAGE_TAG: ${IMAGE_TAG}-dev # Image tag of dev image
SLIM_IMAGE_NAME: ${IMAGE_NAME} # Image name of slim run image
SLIM_IMAGE_TAG: ${IMAGE_TAG}-slim # Image tag of slim run image
BUILD_CONTEXT: . # Build context of Docker build process
REGISTRY: ${CI_REGISTRY} # Docker registry to push images to
REGISTRY_USER: ${CI_REGISTRY_USER} # Docker registry username
REGISTRY_PASSWORD: ${CI_REGISTRY_PASSWORD} # Docker registry password
ENABLE_INDUSTRIAL_CI: 'false' # Enable industrial_ci
ENABLE_SLIM: 'true' # Enable an extra slimmed run image via slim (only if run stage is targeted)
SLIM_BUILD_ARGS: '--sensor-ipc-mode proxy --continue-after=10 --show-clogs --http-probe=false' # Arguments to `slim build` (except for `--target` and `--tag`)
ENABLE_SINGLEARCH_PUSH: 'false' # Enable push of single arch images with [-amd64|-arm64] postfix
ENABLE_PUSH_AS_LATEST: 'false' # Push images with tag `latest`/`latest-dev` in addition to the configured image names
RMW_IMPLEMENTATION: 'rmw_cyclonedds_cpp' # RMW implementation to use (only for ROS 2)
ROS_DISTRO: '' # ROS Distro (required if ROS is not installed in `base-image`)
GIT_HTTPS_SERVER: ${CI_SERVER_HOST} # Server URL (without protocol) for cloning private Git repositories via HTTPS
GIT_HTTPS_USER: gitlab-ci-token # Username for cloning private Git repositories via HTTPS
GIT_HTTPS_PASSWORD: ${CI_JOB_TOKEN} # Password for cloning private Git repositories via HTTPS
GIT_SSH_PRIVATE_KEY: '' # SSH private key for cloning private Git repositories via SSH
GIT_SSH_KNOWN_HOST_KEYS: '' # Known SSH host keys for cloning private Git repositories via SSH (may be obtained using `ssh-keyscan`)
ADDITIONAL_DEBS_FILE: docker/additional-debs.txt # Relative filepath to file containing additional apt deb packages to install
ENABLE_RECURSIVE_ADDITIONAL_DEBS: 'false' # Enable recursive discovery of files named `additional-debs-file`
ADDITIONAL_FILES_DIR: docker/additional-files # Relative path to directory containing additional files to copy into image"
ADDITIONAL_PIP_FILE: docker/additional-pip-requirements.txt # Relative filepath to file containing additional pip packages to install
ENABLE_RECURSIVE_ADDITIONAL_PIP: 'false' # Enable recursive discovery of files named `additional-pip-file`
BLACKLISTED_PACKAGES_FILE: docker/blacklisted-packages.txt # Relative filepath to file containing the blacklisted packages
ENABLE_RECURSIVE_BLACKLISTED_PACKAGES: 'false' # Enable recursive discovery of files named `blacklisted-packages-file`
CUSTOM_SCRIPT_FILE: docker/custom.sh # Relative filepath to script containing custom installation commands
ENABLE_RECURSIVE_CUSTOM_SCRIPT: 'false' # Enable recursive discovery of files named `custom-script-file`
VCS_IMPORT_FILE: .repos # Relative filepath to file containing additional repos to install via vcstools (only relevant if ENABLE_RECURSIVE_VCS_IMPORT=false)
ENABLE_RECURSIVE_VCS_IMPORT: 'true' # Enable recursive discovery of files named `*.repos`
# -----
DOCKER_ROS_GIT_REF: main
_RUN_IMAGE: ${IMAGE_NAME}:${IMAGE_TAG}
_DEV_IMAGE: ${DEV_IMAGE_NAME}:${DEV_IMAGE_TAG}
_SLIM_IMAGE: ${SLIM_IMAGE_NAME}:${SLIM_IMAGE_TAG}
_IMAGE_DEV_CI: ${_DEV_IMAGE}_${CI_COMMIT_REF_SLUG}_ci
_IMAGE_RUN_CI: ${_RUN_IMAGE}_${CI_COMMIT_REF_SLUG}_ci
_IMAGE_SLIM_CI: ${_SLIM_IMAGE}_${CI_COMMIT_REF_SLUG}_ci
_IMAGE_DEV_CI_AMD64: ${_IMAGE_DEV_CI}-amd64
_IMAGE_DEV_CI_ARM64: ${_IMAGE_DEV_CI}-arm64
_IMAGE_RUN_CI_AMD64: ${_IMAGE_RUN_CI}-amd64
_IMAGE_RUN_CI_ARM64: ${_IMAGE_RUN_CI}-arm64
_IMAGE_SLIM_CI_AMD64: ${_IMAGE_SLIM_CI}-amd64
_IMAGE_SLIM_CI_ARM64: ${_IMAGE_SLIM_CI}-arm64
_IMAGE_DEV_LATEST: ${DEV_IMAGE_NAME}:latest-dev
_IMAGE_RUN_LATEST: ${IMAGE_NAME}:latest
_IMAGE_SLIM_LATEST: ${SLIM_IMAGE_NAME}:latest-slim
_IMAGE_DEV_TARGET_TAG: ${_DEV_IMAGE}-${CI_COMMIT_TAG}
_IMAGE_RUN_TARGET_TAG: ${_RUN_IMAGE}-${CI_COMMIT_TAG}
_IMAGE_SLIM_TARGET_TAG: ${_SLIM_IMAGE}-${CI_COMMIT_TAG}
_IMAGE_DEV_TAG: ${DEV_IMAGE_NAME}:${CI_COMMIT_TAG}-dev
_IMAGE_RUN_TAG: ${IMAGE_NAME}:${CI_COMMIT_TAG}
_IMAGE_SLIM_TAG: ${SLIM_IMAGE_NAME}:${CI_COMMIT_TAG}-slim
GIT_SUBMODULE_STRATEGY: recursive
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: /certs
DOCKER_BUILDKIT: 1
stages:
- Build dev Images
- Build run Images
- Test ROS Industrial CI
- Slim Images
- Push Multi-Arch Images
default:
image: docker:20.10.22-git
services:
- docker:20.10.22-dind
tags:
- privileged
- amd64
before_script:
- echo -e "section_start:`date +%s`:setup_section[collapsed=true]\r\e[0K[docker-ros] Setup docker-ros"
- apk add --update bash
- cd ${BUILD_CONTEXT}
- |-
if [[ ! -d docker/docker-ros ]]; then
mkdir -p docker
git clone --depth=1 https://github.com/ika-rwth-aachen/docker-ros.git docker/docker-ros
cd docker/docker-ros
git fetch origin ${DOCKER_ROS_GIT_REF}
git checkout FETCH_HEAD
cd -
fi
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY}
- docker context create buildx-context
- docker buildx create --use buildx-context
- echo -e "section_end:`date +%s`:setup_section\r\e[0K"
.build:
script:
- |-
if [[ ${CI_RUNNER_EXECUTABLE_ARCH} != ${_PLATFORM} && ${CI_RUNNER_EXECUTABLE_ARCH} != linux/${_PLATFORM} ]]; then
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
fi
TARGET=${_TARGET} PLATFORM=${_PLATFORM} ./docker/docker-ros/scripts/ci.sh
echo -e "section_start:`date +%s`:push_section[collapsed=true]\r\e[0K[docker-ros] Push ${IMAGE}"
docker push ${IMAGE}
echo -e "section_end:`date +%s`:push_section\r\e[0K"
dev-amd64:
stage: Build dev Images
extends: .build
rules:
- if: $PLATFORM =~ /.*amd64.*/ && $TARGET =~ /.*dev.*/
variables:
_PLATFORM: amd64
_TARGET: dev
IMAGE: ${_IMAGE_DEV_CI_AMD64}
ENABLE_SINGLEARCH_PUSH: 'true'
ENABLE_SLIM: 'false'
_IMAGE_POSTFIX: _${CI_COMMIT_REF_SLUG}_ci
dev-arm64:
stage: Build dev Images
extends: .build
tags: [privileged, arm64]
rules:
- if: $PLATFORM =~ /.*arm64.*/ && $TARGET =~ /.*dev.*/
variables:
_PLATFORM: arm64
_TARGET: dev
IMAGE: ${_IMAGE_DEV_CI_ARM64}
ENABLE_SINGLEARCH_PUSH: 'true'
ENABLE_SLIM: 'false'
_IMAGE_POSTFIX: _${CI_COMMIT_REF_SLUG}_ci
run-amd64:
stage: Build run Images
extends: .build
needs:
- job: dev-amd64
optional: true
rules:
- if: $PLATFORM =~ /.*amd64.*/ && $TARGET =~ /.*run.*/
variables:
_PLATFORM: amd64
_TARGET: run
IMAGE: ${_IMAGE_RUN_CI_AMD64}
ENABLE_SINGLEARCH_PUSH: 'true'
ENABLE_SLIM: 'false'
_IMAGE_POSTFIX: _${CI_COMMIT_REF_SLUG}_ci
run-arm64:
stage: Build run Images
extends: .build
tags: [privileged, arm64]
needs:
- job: dev-arm64
optional: true
rules:
- if: $PLATFORM =~ /.*arm64.*/ && $TARGET =~ /.*run.*/
variables:
_PLATFORM: arm64
_TARGET: run
IMAGE: ${_IMAGE_RUN_CI_ARM64}
ENABLE_SINGLEARCH_PUSH: 'true'
ENABLE_SLIM: 'false'
_IMAGE_POSTFIX: _${CI_COMMIT_REF_SLUG}_ci
.test:
stage: Test ROS Industrial CI
variables:
UPSTREAM_WORKSPACE: ${BUILD_CONTEXT}/.repos
TARGET_WORKSPACE: ${BUILD_CONTEXT}
ADDITIONAL_DEBS: git
AFTER_INIT_EMBED: git config --global url.https://${GIT_HTTPS_USER}:${GIT_HTTPS_PASSWORD}@${GIT_HTTPS_SERVER}.insteadOf https://${GIT_HTTPS_SERVER}
DOCKER_RUN_OPTS: -u root:root
before_script:
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY}
- apk add --update bash coreutils grep tar
- |-
if [[ ${CI_RUNNER_EXECUTABLE_ARCH} != ${_PLATFORM} && ${CI_RUNNER_EXECUTABLE_ARCH} != linux/${_PLATFORM} ]]; then
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
fi
- git clone --branch master --depth 1 https://github.com/ros-industrial/industrial_ci.git .industrial_ci
- test -f ${BUILD_CONTEXT}/.repos || echo "repositories:" > ${BUILD_CONTEXT}/.repos
- |-
if [ "$RMW_IMPLEMENTATION" = "rmw_zenoh_cpp" ]; then
export UNDERLAY="/opt/ws_rmw_zenoh/install"
fi
script: .industrial_ci/gitlab.sh
Test dev-amd64:
extends: .test
needs:
- job: dev-amd64
rules:
- if: $ENABLE_INDUSTRIAL_CI == 'true' && $PLATFORM =~ /.*amd64.*/ && $TARGET =~ /.*dev.*/
variables:
DOCKER_IMAGE: ${_IMAGE_DEV_CI_AMD64}
_PLATFORM: amd64
Test dev-arm64:
extends: .test
tags: [privileged, arm64]
needs:
- job: dev-arm64
rules:
- if: $ENABLE_INDUSTRIAL_CI == 'true' && $PLATFORM =~ /.*arm64.*/ && $TARGET =~ /.*dev.*/
variables:
DOCKER_IMAGE: ${_IMAGE_DEV_CI_ARM64}
_PLATFORM: arm64
Test run-amd64:
extends: .test
needs:
- job: run-amd64
rules:
- if: $ENABLE_INDUSTRIAL_CI == 'true' && $PLATFORM =~ /.*amd64.*/ && $TARGET !~ /.*dev.*/
variables:
DOCKER_IMAGE: ${_IMAGE_RUN_CI_AMD64}
_PLATFORM: amd64
Test run-arm64:
extends: .test
needs:
- job: run-arm64
rules:
- if: $ENABLE_INDUSTRIAL_CI == 'true' && $PLATFORM =~ /.*arm64.*/ && $TARGET !~ /.*dev.*/
variables:
DOCKER_IMAGE: ${_IMAGE_RUN_CI_ARM64}
_PLATFORM: arm64
.slim:
stage: Slim Images
before_script:
- apk add --update --upgrade curl tar
- curl -L -o ds.tar.gz ${SLIM_DOWNLOAD_URL}
- tar -xvf ds.tar.gz
- cd dist_linux*
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY}
- docker pull ${FAT_IMAGE}
script:
- ./slim build --target ${FAT_IMAGE} --tag ${SLIM_IMAGE} ${SLIM_BUILD_ARGS}
- docker push ${SLIM_IMAGE}
Slim run-amd64:
stage: Slim Images
extends: .slim
needs:
- job: run-amd64
optional: true
- job: Test run-amd64
optional: true
rules:
- if: $ENABLE_SLIM == 'true' && $PLATFORM =~ /.*amd64.*/ && $TARGET =~ /.*run.*/
variables:
FAT_IMAGE: ${_IMAGE_RUN_CI_AMD64}
SLIM_IMAGE: ${_IMAGE_SLIM_CI_AMD64}
SLIM_DOWNLOAD_URL: "https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux.tar.gz"
Slim run-arm64:
stage: Slim Images
extends: .slim
tags: [privileged, arm64]
needs:
- job: run-arm64
optional: true
- job: Test run-arm64
optional: true
rules:
- if: $ENABLE_SLIM == 'true' && $PLATFORM =~ /.*arm64.*/ && $TARGET =~ /.*run.*/
variables:
FAT_IMAGE: ${_IMAGE_RUN_CI_ARM64}
SLIM_IMAGE: ${_IMAGE_SLIM_CI_ARM64}
SLIM_DOWNLOAD_URL: "https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux_arm64.tar.gz"
.push:
needs:
- job: dev-amd64
optional: true
- job: dev-arm64
optional: true
- job: run-amd64
optional: true
- job: run-arm64
optional: true
- job: Test dev-amd64
optional: true
- job: Test dev-arm64
optional: true
- job: Test run-amd64
optional: true
- job: Test run-arm64
optional: true
- job: Slim run-amd64
optional: true
- job: Slim run-arm64
optional: true
rules:
- if: $PLATFORM == '' || $TARGET == ''
when: never
script:
- |-
if [[ "${PLATFORM}" =~ amd64 && "${PLATFORM}" =~ arm64 ]]; then
if [[ "${TARGET}" =~ dev ]]; then
docker manifest create ${IMG_DEV} --amend ${_IMAGE_DEV_CI_AMD64} --amend ${_IMAGE_DEV_CI_ARM64}
docker manifest push ${IMG_DEV}
fi
if [[ "${TARGET}" =~ run ]]; then
docker manifest create ${IMG_RUN} --amend ${_IMAGE_RUN_CI_AMD64} --amend ${_IMAGE_RUN_CI_ARM64}
docker manifest push ${IMG_RUN}
fi
if [[ "${ENABLE_SLIM}" == 'true' && "${TARGET}" =~ run ]]; then
docker manifest create ${IMG_SLIM} --amend ${_IMAGE_SLIM_CI_AMD64} --amend ${_IMAGE_SLIM_CI_ARM64}
docker manifest push ${IMG_SLIM}
fi
elif [[ "${PLATFORM}" =~ amd64 ]]; then
if [[ "${TARGET}" =~ dev ]]; then
docker pull ${_IMAGE_DEV_CI_AMD64}
docker tag ${_IMAGE_DEV_CI_AMD64} ${IMG_DEV}
docker push ${IMG_DEV}
fi
if [[ "${TARGET}" =~ run ]]; then
docker pull ${_IMAGE_RUN_CI_AMD64}
docker tag ${_IMAGE_RUN_CI_AMD64} ${IMG_RUN}
docker push ${IMG_RUN}
fi
if [[ "${ENABLE_SLIM}" == 'true' && "${TARGET}" =~ run ]]; then
docker pull ${_IMAGE_SLIM_CI_AMD64}
docker tag ${_IMAGE_SLIM_CI_AMD64} ${IMG_SLIM}
docker push ${IMG_SLIM}
fi
elif [[ "${PLATFORM}" =~ arm64 ]]; then
if [[ "${TARGET}" =~ dev ]]; then
docker pull ${_IMAGE_DEV_CI_ARM64}
docker tag ${_IMAGE_DEV_CI_ARM64} ${IMG_DEV}
docker push ${IMG_DEV}
fi
if [[ "${TARGET}" =~ run ]]; then
docker pull ${_IMAGE_RUN_CI_ARM64}
docker tag ${_IMAGE_RUN_CI_ARM64} ${IMG_RUN}
docker push ${IMG_RUN}
fi
if [[ "${ENABLE_SLIM}" == 'true' && "${TARGET}" =~ run ]]; then
docker pull ${_IMAGE_SLIM_CI_ARM64}
docker tag ${_IMAGE_SLIM_CI_ARM64} ${IMG_SLIM}
docker push ${IMG_SLIM}
fi
fi
Push CI:
stage: Push Multi-Arch Images
extends: .push
rules:
- !reference [.push, rules]
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
variables:
IMG_DEV: ${_IMAGE_DEV_CI}
IMG_RUN: ${_IMAGE_RUN_CI}
IMG_SLIM: ${_IMAGE_SLIM_CI}
Push:
stage: Push Multi-Arch Images
extends: .push
rules:
- !reference [.push, rules]
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
IMG_DEV: ${_DEV_IMAGE}
IMG_RUN: ${_RUN_IMAGE}
IMG_SLIM: ${_SLIM_IMAGE}
Push latest:
stage: Push Multi-Arch Images
extends: .push
rules:
- !reference [.push, rules]
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $ENABLE_PUSH_AS_LATEST == 'true'
variables:
IMG_DEV: ${_IMAGE_DEV_LATEST}
IMG_RUN: ${_IMAGE_RUN_LATEST}
IMG_SLIM: ${_IMAGE_SLIM_LATEST}
Push target tag:
stage: Push Multi-Arch Images
extends: .push
rules:
- !reference [.push, rules]
- if: $CI_COMMIT_TAG
variables:
IMG_DEV: ${_IMAGE_DEV_TARGET_TAG}
IMG_RUN: ${_IMAGE_RUN_TARGET_TAG}
IMG_SLIM: ${_IMAGE_SLIM_TARGET_TAG}
Push tag:
stage: Push Multi-Arch Images
extends: .push
rules:
- !reference [.push, rules]
- if: $CI_COMMIT_TAG && $ENABLE_PUSH_AS_LATEST == 'true'
variables:
IMG_DEV: ${_IMAGE_DEV_TAG}
IMG_RUN: ${_IMAGE_RUN_TAG}
IMG_SLIM: ${_IMAGE_SLIM_TAG}