-
Notifications
You must be signed in to change notification settings - Fork 13
/
.gitlab-ci.yml
145 lines (145 loc) · 8.44 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
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
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
- build
- test
- manifest
- deploy
include:
- remote: https://gitlab.com/yobasystems/gitlab-ci-templates/raw/master/container_scanning_all_arch.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml
amd64 wordpress build:
image: yobasystems/alpine-docker:dind
stage: build
tags:
- amd64
variables:
CI_APPLICATION_REPOSITORY: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG"
CI_APPLICATION_TAG: "$CI_COMMIT_SHA"
script:
- export COMMIT_TIME=$(git show -s --format=%ct $CI_APPLICATION_TAG)
- echo "$COMMIT_TIME" && echo "$CI_COMMIT_SHORT_SHA"
- apk add --update git
- echo "$CI_JOB_TOKEN" | docker login -u gitlab-ci-token "$DOCKER_REGISTRY" --password-stdin
- cd alpine-php-wordpress-amd64/ && docker build --build-arg VCS_REF=${CI_COMMIT_SHORT_SHA}
--build-arg BUILD_DATE=${COMMIT_TIME} -t $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:amd64
-t $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:x86_64 -t $DOCKER_REGISTRY_DOCKERHUB_REPO:amd64
-t $DOCKER_REGISTRY_DOCKERHUB_REPO:x86_64 -t $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:amd64
-t $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:x86_64 -t ${CI_APPLICATION_REPOSITORY}:${CI_APPLICATION_TAG} --platform linux/amd64 .
- docker push $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:amd64
- docker push $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:x86_64
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
&& docker push $DOCKER_REGISTRY_DOCKERHUB_REPO:amd64
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
&& docker push $DOCKER_REGISTRY_DOCKERHUB_REPO:x86_64
- echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin
&& docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:amd64
- echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin
&& docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:x86_64
- docker push ${CI_APPLICATION_REPOSITORY}:${CI_APPLICATION_TAG}
arm32v7 wordpress build:
image: yobasystems/alpine-docker:dind
stage: build
tags:
- armhf
variables:
CI_APPLICATION_REPOSITORY: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG"
CI_APPLICATION_TAG: "$CI_COMMIT_SHA"
script:
- export COMMIT_TIME=$(git show -s --format=%ct $CI_APPLICATION_TAG)
- echo "$COMMIT_TIME" && echo "$CI_COMMIT_SHORT_SHA"
- apk add --update git
- echo "$CI_JOB_TOKEN" | docker login -u gitlab-ci-token "$DOCKER_REGISTRY" --password-stdin
- cd alpine-php-wordpress-armhf/ && docker build --build-arg VCS_REF=${CI_COMMIT_SHORT_SHA}
--build-arg BUILD_DATE=${COMMIT_TIME} -t $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm32v7
-t $DOCKER_REGISTRY_DOCKERHUB_REPO:arm32v7 -t $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:arm32v7
-t $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:armhf -t $DOCKER_REGISTRY_DOCKERHUB_REPO:armhf
-t $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:armhf --platform linux/arm/v7 .
- docker push $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm32v7
- docker push $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:armhf
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
&& docker push $DOCKER_REGISTRY_DOCKERHUB_REPO:arm32v7
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
&& docker push $DOCKER_REGISTRY_DOCKERHUB_REPO:armhf
- echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin
&& docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:arm32v7
- echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin
&& docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:armhf
arm64v8 wordpress build:
image: yobasystems/alpine-docker:dind
stage: build
tags:
- aarch64
variables:
CI_APPLICATION_REPOSITORY: "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG"
CI_APPLICATION_TAG: "$CI_COMMIT_SHA"
script:
- export COMMIT_TIME=$(git show -s --format=%ct $CI_APPLICATION_TAG)
- echo "$COMMIT_TIME" && echo "$CI_COMMIT_SHORT_SHA"
- apk add --update git
- echo "$CI_JOB_TOKEN" | docker login -u gitlab-ci-token "$DOCKER_REGISTRY" --password-stdin
- cd alpine-php-wordpress-aarch64/ && docker build --build-arg VCS_REF=${CI_COMMIT_SHORT_SHA}
--build-arg BUILD_DATE=${COMMIT_TIME} -t $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm64v8
-t $DOCKER_REGISTRY_DOCKERHUB_REPO:arm64v8 -t $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:arm64v8
-t $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:aarch64 -t $DOCKER_REGISTRY_DOCKERHUB_REPO:aarch64
-t $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:aarch64 --platform linux/arm64/v8 .
- docker push $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm64v8
- docker push $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:aarch64
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
&& docker push $DOCKER_REGISTRY_DOCKERHUB_REPO:arm64v8
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
&& docker push $DOCKER_REGISTRY_DOCKERHUB_REPO:aarch64
- echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin
&& docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:arm64v8
- echo "$QUAY_PASSWORD" | docker login -u "$QUAY_USERNAME" quay.io --password-stdin
&& docker push $DOCKER_REGISTRY_QUAY/$DOCKER_REGISTRY_QUAY_REPO:aarch64
gitlab manifest creation:
image: yobasystems/alpine-docker:dind
stage: manifest
tags:
- amd64
script:
- mkdir /root/.docker
- 'echo -e "{\n \"experimental\": \"enabled\"\n}\n" >> ~/.docker/config.json'
- echo "$CI_JOB_TOKEN" | docker login -u gitlab-ci-token "$DOCKER_REGISTRY" --password-stdin
- docker pull $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:amd64
- docker pull $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm32v7
- docker pull $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm64v8
- docker manifest create $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:latest $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:amd64
$DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm32v7 $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm64v8
- docker manifest annotate $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:latest $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:amd64
--os linux --arch amd64
- docker manifest annotate $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:latest $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm32v7
--os linux --arch arm --variant 7
- docker manifest annotate $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:latest $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:arm64v8
--os linux --arch arm64 --variant 8
- docker manifest push $DOCKER_REGISTRY/$DOCKER_REGISTRY_REPO:latest
dockerhub manifest creation:
image: yobasystems/alpine-docker:dind
stage: manifest
tags:
- amd64
script:
- mkdir /root/.docker
- 'echo -e "{\n \"experimental\": \"enabled\"\n}\n" >> ~/.docker/config.json'
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
- docker pull $DOCKER_REGISTRY_DOCKERHUB_REPO:amd64
- docker pull $DOCKER_REGISTRY_DOCKERHUB_REPO:arm32v7
- docker pull $DOCKER_REGISTRY_DOCKERHUB_REPO:arm64v8
- docker manifest create $DOCKER_REGISTRY_DOCKERHUB_REPO:latest $DOCKER_REGISTRY_DOCKERHUB_REPO:amd64
$DOCKER_REGISTRY_DOCKERHUB_REPO:arm32v7 $DOCKER_REGISTRY_DOCKERHUB_REPO:arm64v8
- docker manifest annotate $DOCKER_REGISTRY_DOCKERHUB_REPO:latest $DOCKER_REGISTRY_DOCKERHUB_REPO:amd64
--os linux --arch amd64
- docker manifest annotate $DOCKER_REGISTRY_DOCKERHUB_REPO:latest $DOCKER_REGISTRY_DOCKERHUB_REPO:arm32v7
--os linux --arch arm --variant 7
- docker manifest annotate $DOCKER_REGISTRY_DOCKERHUB_REPO:latest $DOCKER_REGISTRY_DOCKERHUB_REPO:arm64v8
--os linux --arch arm64 --variant 8
- docker manifest push $DOCKER_REGISTRY_DOCKERHUB_REPO:latest
sast:
stage: test