forked from apache/streampipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
234 lines (225 loc) · 11.2 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
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
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
variables:
IMAGE_NAME: $REGISTRY_HOST/$CI_PROJECT_PATH
HARBOR_IMAGE_NAME: $HARBOR_REGISTRY_HOST/$CI_PROJECT_PATH
MAVEN_CLI_OPTS: -DskipTests --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true
GIT_REPO_ORIGIN: $GIT_REPO_ORIGIN
GIT_STRATEGY: clone
DOCKER_CLI_EXPERIMENTAL: enabled
BASE_IMAGE_AMD64: adoptopenjdk/openjdk8-openj9:alpine
BASE_IMAGE_ARM32v7: arm32v7/openjdk:11-jre-slim
BASE_IMAGE_ARM64v8: arm64v8/openjdk:11-jre-slim
BASE_NGINX_AMD64: nginx
BASE_NGINX_ARM32v7: arm32v7/nginx
BASE_NGINX_ARM64v8: arm64v8/nginx
stages:
- github
- build
- docker
pull github:
image: maven:3-jdk-8
stage: github
script:
- git remote set-url origin $GIT_REPO_ORIGIN/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME.git
- git remote add github https://github.com/apache/incubator-streampipes.git
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH")
- mkdir ~/.ssh
- touch ~/.ssh/known_hosts
- ssh-keyscan -p 2222 -t rsa $GITLAB_HOST > ~/.ssh/known_hosts
- git config --global user.email '$USER_EMAIL'
- git config --global user.name '$USER_NAME'
- git checkout dev
- git pull github dev --allow-unrelated-histories
- git push origin --all
build:
image: maven:3-jdk-8
stage: build
script:
- echo "$GPG_PRIVATE_KEY" | gpg --batch --import --passphrase "$GPG_PASSPHRASE"
- echo "$MAVEN_CREDENTIALS" > /root/.m2/settings.xml
- mvn clean package javadoc:aggregate
# - mvn clean package javadoc:aggregate
- export MVN_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\[')
- "echo $MVN_VERSION >> ./target/mvn_version"
artifacts:
paths:
- ./streampipes-backend/target/streampipes-backend.jar
- ./streampipes-connect-container-master/target/streampipes-connect-container-master.jar
- ./target/site/apidocs/**
- ./target/mvn_version
expire_in: 1 week
except:
- /release-.*$/
build-ui:
image: node:8-alpine
stage: build
script:
- cd ui
- export NODE_PATH=/cache/node_modules
- export NODE_OPTIONS=--max_old_space_size=4096
- npm install --unsafe-perm
- npm run build
artifacts:
paths:
- ui/dist/assets/css/
- ui/dist/assets/img/
- ui/dist/assets/lib/
- ui/dist/assets/templates/
- ui/dist/assets/fonts/
- ui/dist/index.html
- ui/dist/main.bundle.js
- ui/dist/main.bundle.js.gz
- ui/dist/polyfills.bundle.js
- ui/dist/polyfills.bundle.js.gz
- ui/dist/style.bundle.css
- ui/dist/style.bundle.css.gz
- ui/dist/style.bundle.js
- ui/dist/style.bundle.js.gz
- ui/dist/style.css
- ui/dist/style.css.gz
expire_in: 1 hour
only:
- dev
docker-ui:
image: docker:19.03.5
stage: docker
dependencies:
- build
- build-ui
script:
- export MVN_VERSION=$(cat ./target/mvn_version)
- apk update
- apk add curl
- apk add unzip
- apk add bash
# - 'curl -k -f -L -H "PRIVATE-TOKEN: ${API_KEY}" -o javadoc.zip "https://ipe-wim-gitlab.fzi.de/streampipes/ce/-/jobs/artifacts/dev/download?job=build"'
# - unzip javadoc.zip
# - mkdir javadoc && mv target/site/apidocs/* ./javadoc
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $REGISTRY_HOST
# Build AMD64
- docker build --pull --build-arg BASE_IMAGE=$BASE_NGINX_AMD64
-t $IMAGE_NAME/ui:amd64 -t $IMAGE_NAME/ui:amd64-$MVN_VERSION
-f ./ui/Dockerfile ./ui
# Build ARM32v7, ARM64v8
# Download qemu static and make it executable so it can be used during the docker build phase
- wget https://github.com/multiarch/qemu-user-static/releases/download/v4.0.0/qemu-arm-static -P ./ui
- wget https://github.com/multiarch/qemu-user-static/releases/download/v4.0.0/qemu-aarch64-static -P ./ui
- chmod 554 ./ui/qemu-arm-static
- chmod 554 ./ui/qemu-aarch64-static
- docker build --pull --build-arg BASE_IMAGE=$BASE_NGINX_ARM32v7 --build-arg QEMU=qemu-arm-static
-t $IMAGE_NAME/ui:arm32v7 -t $IMAGE_NAME/ui:arm32v7-$MVN_VERSION
-f ./ui/arm.Dockerfile ./ui
- docker build --pull --build-arg BASE_IMAGE=$BASE_NGINX_ARM64v8 --build-arg QEMU=qemu-aarch64-static
-t $IMAGE_NAME/ui:arm64v8 -t $IMAGE_NAME/ui:arm64v8-$MVN_VERSION
-f ./ui/aarch64.Dockerfile ./ui
# Push Docker images: AMD64, ARM32v7, ARM64v8
- docker push $IMAGE_NAME/ui:amd64-$MVN_VERSION
- docker push $IMAGE_NAME/ui:amd64
- docker push $IMAGE_NAME/ui:arm32v7-$MVN_VERSION
- docker push $IMAGE_NAME/ui:arm32v7
- docker push $IMAGE_NAME/ui:arm64v8-$MVN_VERSION
- docker push $IMAGE_NAME/ui:arm64v8
# Create Docker manifest
- docker manifest create $IMAGE_NAME/ui:$MVN_VERSION
$IMAGE_NAME/ui:amd64-$MVN_VERSION
$IMAGE_NAME/ui:arm32v7-$MVN_VERSION
$IMAGE_NAME/ui:arm64v8-$MVN_VERSION
- docker manifest annotate $IMAGE_NAME/ui:$MVN_VERSION $IMAGE_NAME/ui:arm32v7-$MVN_VERSION --os linux --arch arm
- docker manifest annotate $IMAGE_NAME/ui:$MVN_VERSION $IMAGE_NAME/ui:arm64v8-$MVN_VERSION --os linux --arch arm64
- docker manifest push $IMAGE_NAME/ui:$MVN_VERSION
docker-backend:
image: docker:19.03.5
stage: docker
dependencies:
- build
script:
- export MVN_VERSION=$(cat ./target/mvn_version)
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $REGISTRY_HOST
# Build AMD64
- docker build --pull --build-arg BASE_IMAGE=$BASE_IMAGE_AMD64
-t $IMAGE_NAME/backend:amd64 -t $IMAGE_NAME/backend:amd64-$MVN_VERSION
-f ./streampipes-backend/Dockerfile ./streampipes-backend
# Build ARM32v7, ARM64v8
# Download qemu static and make it executable so it can be used during the docker build phase
- wget https://github.com/multiarch/qemu-user-static/releases/download/v4.0.0/qemu-arm-static -P ./streampipes-backend
- wget https://github.com/multiarch/qemu-user-static/releases/download/v4.0.0/qemu-aarch64-static -P ./streampipes-backend
- chmod 554 ./streampipes-backend/qemu-arm-static
- chmod 554 ./streampipes-backend/qemu-aarch64-static
- docker build --pull --build-arg BASE_IMAGE=$BASE_IMAGE_ARM32v7 --build-arg QEMU=qemu-arm-static
-t $IMAGE_NAME/backend:arm32v7 -t $IMAGE_NAME/backend:arm32v7-$MVN_VERSION
-f ./streampipes-backend/arm.Dockerfile ./streampipes-backend
- docker build --pull --build-arg BASE_IMAGE=$BASE_IMAGE_ARM64v8 --build-arg QEMU=qemu-aarch64-static
-t $IMAGE_NAME/backend:arm64v8 -t $IMAGE_NAME/backend:arm64v8-$MVN_VERSION
-f ./streampipes-backend/aarch64.Dockerfile ./streampipes-backend
# Push Docker images: AMD64, ARM32v7, ARM64v8
- docker push $IMAGE_NAME/backend:amd64-$MVN_VERSION
- docker push $IMAGE_NAME/backend:amd64
- docker push $IMAGE_NAME/backend:arm32v7-$MVN_VERSION
- docker push $IMAGE_NAME/backend:arm32v7
- docker push $IMAGE_NAME/backend:arm64v8-$MVN_VERSION
- docker push $IMAGE_NAME/backend:arm64v8
# Create Docker manifest
- docker manifest create $IMAGE_NAME/backend:$MVN_VERSION
$IMAGE_NAME/backend:amd64-$MVN_VERSION
$IMAGE_NAME/backend:arm32v7-$MVN_VERSION
$IMAGE_NAME/backend:arm64v8-$MVN_VERSION
- docker manifest annotate $IMAGE_NAME/backend:$MVN_VERSION $IMAGE_NAME/backend:arm32v7-$MVN_VERSION --os linux --arch arm
- docker manifest annotate $IMAGE_NAME/backend:$MVN_VERSION $IMAGE_NAME/backend:arm64v8-$MVN_VERSION --os linux --arch arm64
- docker manifest push $IMAGE_NAME/backend:$MVN_VERSION
only:
- dev
docker-connect-container:
image: docker:19.03.5
stage: docker
dependencies:
- build
script:
- export MVN_VERSION=$(cat ./target/mvn_version)
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $REGISTRY_HOST
# Build AMD64
- docker build --pull --build-arg BASE_IMAGE=$BASE_IMAGE_AMD64
-t $IMAGE_NAME/streampipes-connect-container:amd64 -t $IMAGE_NAME/streampipes-connect-container:amd64-$MVN_VERSION
-f ./streampipes-connect-container-master/Dockerfile ./streampipes-connect-container-master
# Build ARM32v7,ARM64v8
# Download qemu static and make it executable so it can be used during the docker build phase
- wget https://github.com/multiarch/qemu-user-static/releases/download/v4.0.0/qemu-arm-static -P ./streampipes-connect-container-master
- wget https://github.com/multiarch/qemu-user-static/releases/download/v4.0.0/qemu-aarch64-static -P ./streampipes-connect-container-master
- chmod 554 ./streampipes-connect-container-master/qemu-arm-static
- chmod 554 ./streampipes-connect-container-master/qemu-aarch64-static
- docker build --pull --build-arg BASE_IMAGE=$BASE_IMAGE_ARM32v7 --build-arg QEMU=qemu-arm-static
-t $IMAGE_NAME/streampipes-connect-container:arm32v7 -t $IMAGE_NAME/streampipes-connect-container:arm32v7-$MVN_VERSION
-f ./streampipes-connect-container-master/arm.Dockerfile ./streampipes-connect-container-master
- docker build --pull --build-arg BASE_IMAGE=$BASE_IMAGE_ARM64v8 --build-arg QEMU=qemu-aarch64-static
-t $IMAGE_NAME/streampipes-connect-container:arm64v8 -t $IMAGE_NAME/streampipes-connect-container:arm64v8-$MVN_VERSION
-f ./streampipes-connect-container-master/aarch64.Dockerfile ./streampipes-connect-container-master
# Push Docker images: AMD64, ARM32v7, ARM64v8
- docker push $IMAGE_NAME/streampipes-connect-container:amd64-$MVN_VERSION
- docker push $IMAGE_NAME/streampipes-connect-container:amd64
- docker push $IMAGE_NAME/streampipes-connect-container:arm32v7-$MVN_VERSION
- docker push $IMAGE_NAME/streampipes-connect-container:arm32v7
- docker push $IMAGE_NAME/streampipes-connect-container:arm64v8-$MVN_VERSION
- docker push $IMAGE_NAME/streampipes-connect-container:arm64v8
# Create Docker manifest
- docker manifest create $IMAGE_NAME/streampipes-connect-container:$MVN_VERSION
$IMAGE_NAME/streampipes-connect-container:amd64-$MVN_VERSION
$IMAGE_NAME/streampipes-connect-container:arm32v7-$MVN_VERSION
$IMAGE_NAME/streampipes-connect-container:arm64v8-$MVN_VERSION
- docker manifest annotate $IMAGE_NAME/streampipes-connect-container:$MVN_VERSION $IMAGE_NAME/streampipes-connect-container:arm32v7-$MVN_VERSION --os linux --arch arm
- docker manifest annotate $IMAGE_NAME/streampipes-connect-container:$MVN_VERSION $IMAGE_NAME/streampipes-connect-container:arm64v8-$MVN_VERSION --os linux --arch arm64
- docker manifest push $IMAGE_NAME/streampipes-connect-container:$MVN_VERSION
only:
- dev