-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
107 lines (103 loc) · 3.26 KB
/
.gitlab-ci.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
.before-script-build: &before-script-build
- |
if [[ ! -z "$CI_BUILD_PLATFORMS" ]]; then
export OS_ARCH=`echo $CI_BUILD_PLATFORMS | tr ' ' '\n' | \
sed 's|\/||2' | sed 's|\/|-|' | tr '\n' ' '`
fi
- export CI_APP_REPO=${CI_APP_REPO:-$CI_REGISTRY_IMAGE}
- >
echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER
--password-stdin $CI_REGISTRY
- |
if [[ -z "$GIT_LFS_VERSION" ]]; then
export GIT_LFS_VERSION=`sed -n "s|GIT_LFS_VERSION=\(.*\)|\1|p" sample..env`
fi
.build:
image: glcr.b-data.ch/docker/docker:dind
stage: build
services:
- name: glcr.b-data.ch/docker/docker:dind
alias: docker
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
BUILDX_NO_DEFAULT_ATTESTATIONS: "true"
before_script:
- *before-script-build
build:version-linux-amd64:
extends: .build
tags:
- arch:amd64
- os:linux
script:
- >
docker build
--build-arg IMAGE
--build-arg GIT_LFS_VERSION
-t $CI_APP_REPO:$GIT_LFS_VERSION-linux-amd64
-f build.Dockerfile .
- docker push $CI_APP_REPO:$GIT_LFS_VERSION-linux-amd64
- |
if [[ "$TAG_LATEST" == "true" ]]; then
docker tag $CI_APP_REPO:$GIT_LFS_VERSION-linux-amd64 \
$CI_APP_REPO:latest-linux-amd64
docker push $CI_APP_REPO:latest-linux-amd64
fi
rules:
- if: $CI_COMMIT_BRANCH == "main" && $CI_BUILD_PLATFORMS =~ /(linux\/amd64)/
changes:
- build.Dockerfile
- sample..env
build:version-linux-arm64v8:
extends: .build
tags:
- arch:arm64/v8
- os:linux
script:
- >
docker build
--build-arg IMAGE
--build-arg GIT_LFS_VERSION
-t $CI_APP_REPO:$GIT_LFS_VERSION-linux-arm64v8
-f build.Dockerfile .
- docker push $CI_APP_REPO:$GIT_LFS_VERSION-linux-arm64v8
- |
if [[ "$TAG_LATEST" == "true" ]]; then
docker tag $CI_APP_REPO:$GIT_LFS_VERSION-linux-arm64v8 \
$CI_APP_REPO:latest-linux-arm64v8
docker push $CI_APP_REPO:latest-linux-arm64v8
fi
rules:
- if: $CI_COMMIT_BRANCH == "main" && $CI_BUILD_PLATFORMS =~ /(linux\/arm64\/v8)/
changes:
- build.Dockerfile
- sample..env
build-manifest:version-linux-multiarch:
extends: .build
needs: ["build:version-linux-amd64", "build:version-linux-arm64v8"]
script:
- |
for i in $OS_ARCH; do
export CI_MANIFEST_LIST="$CI_MANIFEST_LIST $CI_APP_REPO:$GIT_LFS_VERSION-$i"
done
- |
docker manifest create $CI_APP_REPO:$GIT_LFS_VERSION $CI_MANIFEST_LIST
if echo $OS_ARCH | grep "linux-arm64v8" >/dev/null ; then
docker manifest annotate --variant v8 $CI_APP_REPO:$GIT_LFS_VERSION \
$CI_APP_REPO:$GIT_LFS_VERSION-linux-arm64v8
fi
docker manifest push $CI_APP_REPO:$GIT_LFS_VERSION
- |
if [[ "$TAG_LATEST" == "true" ]]; then
docker manifest create $CI_APP_REPO:latest $CI_MANIFEST_LIST
if echo $OS_ARCH | grep "linux-arm64v8" >/dev/null ; then
docker manifest annotate --variant v8 $CI_APP_REPO:latest \
$CI_APP_REPO:$GIT_LFS_VERSION-linux-arm64v8
fi
docker manifest push $CI_APP_REPO:latest
fi
rules:
- if: $CI_COMMIT_BRANCH == "main"
changes:
- build.Dockerfile
- sample..env