-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
89 lines (84 loc) · 3.28 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
stages:
- build
variables:
DOCKER_TLS_CERTDIR: ""
build:
stage: build
image: docker:20.10.17
services:
- name: docker:20.10.17-dind
command: ["--tls=false"]
- name: dev.privmx.com:5050/teamserverdev/privmx-server-ee/mongo-with-rs2:7
alias: mongodb
script:
- export MONGODB_IP=$(cat /etc/hosts | grep mongodb | awk '{print $1}')
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- ./scripts/build-base-images.sh
- docker build --cache-from dev.privmx.com:5050/teamserverdev/privmx-server-ee/node-python3:22.11.0-bullseye-slim --cache-from dev.privmx.com:5050/teamserverdev/privmx-server-ee/node-ssl:22.11.0-bullseye-slim --add-host=mongodb:$MONGODB_IP --build-arg "MONGO_URL=mongodb://mongodb" .
except:
- tags
- master
- /^hotfix-.*$/
build_and_publish_docker_base_image:
stage: build
image: docker:20.10.17
services:
- name: docker:20.10.17-dind
command: ["--tls=false"]
- name: dev.privmx.com:5050/teamserverdev/privmx-server-ee/mongo-with-rs2:7
alias: mongodb
script:
- export MONGODB_IP=$(cat /etc/hosts | grep mongodb | awk '{print $1}')
- export IMAGE_ID=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
- export IMAGE_ID_AMD64=$IMAGE_ID-amd64
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- ./scripts/build-base-images.sh
- docker build --cache-from dev.privmx.com:5050/teamserverdev/privmx-server-ee/node-python3:22.11.0-bullseye-slim --cache-from dev.privmx.com:5050/teamserverdev/privmx-server-ee/node-ssl:22.11.0-bullseye-slim --add-host=mongodb:$MONGODB_IP --build-arg "MONGO_URL=mongodb://mongodb" -t $IMAGE_ID_AMD64 .
- docker push $IMAGE_ID_AMD64
except:
- tags
only:
- master
- /^hotfix-.*$/
# These two stages could be merged, but the second `docker build` does not consider the --platform argument of the FROM directive, so they have to be separated.
build_multi_arch_docker_image:
stage: build
needs:
- build_and_publish_docker_base_image
image: docker:20.10.17
services:
- name: docker:20.10.17-dind
command: ["--tls=false"]
script:
- export IMAGE_ID=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
- export IMAGE_ID_AMD64=$IMAGE_ID-amd64
- export IMAGE_ID_ARM64=$IMAGE_ID-arm64-v8
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $IMAGE_ID_AMD64
- ./scripts/build-docker-for-platform.sh $IMAGE_ID_AMD64 arm64/v8 $IMAGE_ID_ARM64
- docker push $IMAGE_ID_ARM64
- docker manifest create $IMAGE_ID $IMAGE_ID_AMD64 $IMAGE_ID_ARM64
- docker manifest annotate --arch amd64 $IMAGE_ID $IMAGE_ID_AMD64
- docker manifest annotate --arch arm64 --variant v8 $IMAGE_ID $IMAGE_ID_ARM64
- docker manifest push $IMAGE_ID
except:
- tags
only:
- master
- /^hotfix-.*$/
tag_docker_image:
stage: build
image: docker:20.10.17
services:
- name: docker:20.10.17-dind
command: ["--tls=false"]
script:
- export IMAGE_ID=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
- export IMAGE_TAG_ID=$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker manifest inspect $IMAGE_ID
- docker buildx imagetools create -t $IMAGE_TAG_ID $IMAGE_ID
except:
- branches
only:
- tags