-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
54 lines (49 loc) · 1.4 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
image: docker:19.03.12
stages:
- build
- deploy
variables:
CONTAINER_NAME: config-server
build:
image: gradle:6.9.0-jdk11
stage: build
script:
- gradle build -x test
artifacts:
paths:
- build/libs/*.jar
cache:
key: ${CI_COMMIT_REF_SLUG}-${CI_PIPELINE_ID}
policy: push
paths:
- build/libs/*.jar
build-docker-image:
stage: build
cache:
key: ${CI_COMMIT_REF_SLUG}-${CI_PIPELINE_ID}
policy: pull
paths:
- build/libs/*.jar
script:
- docker login -u $DOCKER_HUB_ID -p $DOCKER_HUB_PASSWORD
- docker build -t $DOCKER_HUB_ID/$IMAGE_NAME .
- docker push $DOCKER_HUB_ID/$IMAGE_NAME
deploy:
stage: deploy
script:
- docker pull $DOCKER_HUB_ID/$IMAGE_NAME
- "{ docker stop $CONTAINER_NAME; docker rm $CONTAINER_NAME; } || true"
- "docker run -d -p $CONFIG_SERVER_PORT:$CONFIG_SERVER_PORT \
--network $DOCKER_MESH_NETWORK \
--name $CONTAINER_NAME \
-v /root/keystore:/keystore \
-e RABBIT_MQ_HOST_IP=$RABBIT_MQ_HOST_IP \
-e RABBIT_MQ_PORT=$RABBIT_MQ_PORT \
-e RABBIT_MQ_USERNAME=$RABBIT_MQ_USERNAME \
-e RABBIT_MQ_PASSWORD=$RABBIT_MQ_PASSWORD \
-e GITLAB_CONFIG_SERVER_URL=$GITLAB_CONFIG_SERVER_URL \
-e GITLAB_USERNAME=$GITLAB_USERNAME \
-e GITLAB_PASSWORD=$GITLAB_PASSWORD \
-e KEY_STORE_LOCATION=$KEY_STORE_LOCATION \
-e KEY_STORE_PASSWORD=$KEY_STORE_PASSWORD \
$DOCKER_HUB_ID/$IMAGE_NAME"