This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
140 lines (121 loc) · 4.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
image: docker
services:
- docker:stable-dind
stages:
- build
- test
- analyze
- deploy
cache:
key: "$CI_JOB_NAME"
paths:
- aggregator/.m2
untracked: true
variables:
GIT_SUBMODULE_STRATEGY: recursive
################################################################################
# Job-Templates
.job-template: &add-services
variables:
DB_PORT: "5432"
DB_USER: "postgres"
DB_PW: "DXxCNtfnt!MOo!f8LY1!P%sw3KGzt@s!"
AUTHN_SECRET: "89#s3cr3t_15"
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
AGGREGATOR_NAME: "aggregator:8888"
################################################################################
# Jobs
build_test_images:
image: docker
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
# Build aggregator
- docker build -t $CI_REGISTRY_IMAGE --pull aggregator
- docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE:testing
- docker push $CI_REGISTRY_IMAGE:testing
# Build elasticsearch
- docker build -t $CI_REGISTRY_IMAGE/search --pull elasticsearch/
- docker tag $CI_REGISTRY_IMAGE/search $CI_REGISTRY_IMAGE/search:testing
- docker push $CI_REGISTRY_IMAGE/search:testing
idiomatic?:
image: clojure:alpine
stage: test
script:
- cd aggregator
- lein kibit
allow_failure: true
test:
<<: *add-services
stage: test
image: docker
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker pull $CI_REGISTRY/cn-tsn/project/dbas/dbas/db:latest
- docker pull $CI_REGISTRY/cn-tsn/project/dbas/dbas:latest
- docker pull $CI_REGISTRY_IMAGE/search:testing
- docker pull $CI_REGISTRY_IMAGE:testing
- docker network create -d bridge dbas_$CI_JOB_ID
- docker run -d --name db_$CI_JOB_ID --net=dbas_$CI_JOB_ID $CI_REGISTRY/cn-tsn/project/dbas/dbas/db:latest
- sleep 10 # init dbas' database
- docker run -d --name web_$CI_JOB_ID --net=dbas_$CI_JOB_ID -e DB_PW=DXxCNtfnt!MOo!f8LY1!P%sw3KGzt@s! -e DB_NAME=discussion -e DB_USER=postgres -e DB_PORT=5432 -e DB_HOST=db_$CI_JOB_ID -e AUTHN_SECRET=89#s3cr3t_15 -e KEY_PATH=devkey.pem -e PUBKEY_PATH=devpublic.pem $CI_REGISTRY/cn-tsn/project/dbas/dbas:development
- sleep 20 # give the web instance time to start
- docker run -d --name search_$CI_JOB_ID --net=dbas_$CI_JOB_ID $CI_REGISTRY_IMAGE/search:testing
script:
- cd aggregator
- docker run -d --net=dbas_$CI_JOB_ID --env-file ../.env --name aggregator_$CI_JOB_ID -e DBAS_HOST=web_$CI_JOB_ID -e ELASTICSEARCH_HOST=search_$CI_JOB_ID $CI_REGISTRY_IMAGE:testing
- sleep 30 #Wait for container to properly start
- docker exec aggregator_$CI_JOB_ID lein cloverage
after_script:
- docker kill db_$CI_JOB_ID web_$CI_JOB_ID search_$CI_JOB_ID aggregator_$CI_JOB_ID|| true
- docker network rm dbas_$CI_JOB_ID || true
################################
# Deploy Images
################################
build_dev_images:
image: docker
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
# Build aggregator
- docker build -t $CI_REGISTRY_IMAGE --pull aggregator
- docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE:develop
- docker push $CI_REGISTRY_IMAGE:develop
# Build elasticsearch
- docker build -t $CI_REGISTRY_IMAGE/search --pull elasticsearch/
- docker tag $CI_REGISTRY_IMAGE/search $CI_REGISTRY_IMAGE/search:develop
- docker push $CI_REGISTRY_IMAGE/search:develop
only:
- develop
build_master_images:
image: docker
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
# Build aggregator
- docker build -t $CI_REGISTRY_IMAGE --pull aggregator
- docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE
- docker push $CI_REGISTRY_IMAGE
# Build elasticsearch
- docker build -t $CI_REGISTRY_IMAGE/search --pull elasticsearch/
- docker tag $CI_REGISTRY_IMAGE/search $CI_REGISTRY_IMAGE/search
- docker push $CI_REGISTRY_IMAGE/search
only:
- master
deploy_docs:
image: $CI_REGISTRY_IMAGE
stage: deploy
script:
- cd /code
- lein codox
- cd /code/target/default/doc
- apk add git
- git config --global user.email "alexander@schneider.gg"
- git config --global user.name "GITLAB-CI"
- git init
- git add .
- git commit -m "$CI_COMMIT_MESSAGE"
- git remote add origin https://hhucn-mirror:$GITHUB_TOKEN@github.com/hhucn/eden-docs.git
- git push -u origin master:gh-pages --force
only:
- master