-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
282 lines (260 loc) · 16.3 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
---
image: gitlab/dind
variables:
CONTAINER_TEST_IMAGE: $REGISTRY_ADDR/hexaa/hexaa-frontend:$CI_COMMIT_REF_NAME
CONTAINER_DEVELOPMENT_IMAGE: $REGISTRY_ADDR/hexaa/hexaa-frontend:development
CONTAINER_STAGING_IMAGE: $REGISTRY_ADDR/hexaa/hexaa-frontend:staging
CONTAINER_STABLE_IMAGE: $REGISTRY_ADDR/hexaa/hexaa-frontend:latest
CONTAINER_STAGING_RELEASE_IMAGE: hexaaproject/hexaa-frontend:staging
CONTAINER_STABLE_RELEASE_IMAGE: hexaaproject/hexaa-frontend:latest
services:
- docker:dind
stages:
- build
# - test
- release
- deploy
before_script:
- docker info
- whoami
- hostname
# Log into our private docker hub
- docker login -u $REGISTRY_USER -p $REGISTRY_PASS $REGISTRY_ADDR
# Install ssh-agent if not already installed, it is required by Docker.
# (change apt-get to yum if you use a CentOS-based image)
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$SSH_PRIVATE_KEY")
# For Docker builds disable host key checking. Be aware that by adding that
# you are suspectible to man-in-the-middle attacks.
# WARNING: Use this only with the Docker executor, if you use it with shell
# you will overwrite your user's SSH config.
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
build:
stage: build
script:
- docker build -t $CONTAINER_TEST_IMAGE -f docker-prod/Dockerfile .
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_DEVELOPMENT_IMAGE
- docker push $CONTAINER_TEST_IMAGE
- docker push $CONTAINER_DEVELOPMENT_IMAGE
except:
- staging
build_staging:
stage: build
script:
- docker build -t $CONTAINER_TEST_IMAGE -f docker-prod/Dockerfile .
- docker push $CONTAINER_TEST_IMAGE
tags:
- dind
only:
- staging
# TODO: switch to use new containers.
#
#code_style_check:
# stage: test
# script:
# - docker run -d --name frontend $CONTAINER_TEST_IMAGE
# - docker exec -t frontend /opt/hexaa-frontend/phpcs.sh
# - docker exec -t frontend sh -c '/opt/hexaa-frontend/vendor/bin/var-dump-check --no-colors --symfony --exclude /opt/hexaa-frontend/vendor /opt/hexaa-frontend'
# tags:
# - dind
#
#test-organization:
# stage: test
# script:
# - docker network create hexaa-test
# - docker run --network=hexaa-test -d --name db -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_USER=someuser -e MYSQL_PASSWORD=somepass -e MYSQL_DATABASE=hexaa -v /builds/hexaa/hexaa-frontend/docker-prod/mysql_test_data_dump.sql:/docker-entrypoint-initdb.d/01-test_data.sql mariadb:10.2
# - docker run --network=hexaa-test -d --name memcached memcached
# - docker run --network=hexaa-test -d --name grid -e USE_SELENIUM=2 elgalu/selenium:3.2.0-p4
# - docker run --network=hexaa-test -d --name smtp mailhog/mailhog
# - docker run --network=hexaa-test -d --name frontend -v hexaa_ui_source:/opt/hexaa-frontend -e HEXAA_FRONTEND_API_BASE_URL="http://web/backend/api/" -e HEXAA_FRONTEND_MAILER_PORT=1025 $CONTAINER_TEST_IMAGE
# - docker run --network=hexaa-test dmfenton/wait db:3306 -t 120
# - docker run --network=hexaa-test -d --name backend -v hexaa_backend_source:/opt/hexaa-backend -v /builds/hexaa/hexaa-frontend/docker-prod/hexaa_entityids.yml:/opt/hexaa-backend/app/config/hexaa_entityids.yml -e HEXAA_BACKEND_DATABASE_USER=someuser -e HEXAA_BACKEND_DATABASE_PASSWORD=somepass -e [email protected] hexaaproject/hexaa-backend:new-api-dev
# - docker run --network=hexaa-test -d --name web -v hexaa_ui_source:/opt/hexaa-frontend -v hexaa_backend_source:/opt/hexaa-backend -v /builds/hexaa/hexaa-frontend/docker-prod/default-hexaa-fakeshib.conf:/etc/apache2/sites-enabled/000-default.conf -e APACHE_SHIB_APACHE_MODULES_TO_START="rewrite proxy proxy_fcgi" -e APACHE_SHIB_APACHE_START_SHIB=false solazs/apache-shib
# - docker run --network=hexaa-test dmfenton/wait grid:24444 -t 120
# - docker run --network=hexaa-test dmfenton/wait smtp:1025 -t 120
# - docker run --network=hexaa-test dmfenton/wait smtp:8025 -t 120
# - docker run --network=hexaa-test dmfenton/wait web:80 -t 120
# - docker exec -t frontend sh -c '/opt/hexaa-frontend/vendor/bin/behat -c /opt/hexaa-frontend/behat.yml -n --tags organization'
# tags:
# - dind
#
#test-service:
# stage: test
# script:
# - docker network create hexaa-test
# - docker run --network=hexaa-test -d --name db -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_USER=someuser -e MYSQL_PASSWORD=somepass -e MYSQL_DATABASE=hexaa -v /builds/hexaa/hexaa-frontend/docker-prod/mysql_test_data_dump.sql:/docker-entrypoint-initdb.d/01-test_data.sql mariadb:10.2
# - docker run --network=hexaa-test -d --name memcached memcached
# - docker run --network=hexaa-test -d --name grid -e USE_SELENIUM=2 elgalu/selenium:3.2.0-p4
# - docker run --network=hexaa-test -d --name smtp mailhog/mailhog
# - docker run --network=hexaa-test -d --name frontend -v hexaa_ui_source:/opt/hexaa-frontend -e HEXAA_FRONTEND_API_BASE_URL="http://web/backend/api/" -e HEXAA_FRONTEND_MAILER_PORT=1025 $CONTAINER_TEST_IMAGE
# - docker run --network=hexaa-test dmfenton/wait db:3306 -t 120
# - docker run --network=hexaa-test -d --name backend -v hexaa_backend_source:/opt/hexaa-backend -v /builds/hexaa/hexaa-frontend/docker-prod/hexaa_entityids.yml:/opt/hexaa-backend/app/config/hexaa_entityids.yml -e HEXAA_BACKEND_DATABASE_USER=someuser -e HEXAA_BACKEND_DATABASE_PASSWORD=somepass -e [email protected] hexaaproject/hexaa-backend:new-api-dev
# - docker run --network=hexaa-test -d --name web -v hexaa_ui_source:/opt/hexaa-frontend -v hexaa_backend_source:/opt/hexaa-backend -v /builds/hexaa/hexaa-frontend/docker-prod/default-hexaa-fakeshib.conf:/etc/apache2/sites-enabled/000-default.conf -e APACHE_SHIB_APACHE_MODULES_TO_START="rewrite proxy proxy_fcgi" -e APACHE_SHIB_APACHE_START_SHIB=false solazs/apache-shib
# - docker run --network=hexaa-test dmfenton/wait grid:24444 -t 120
# - docker run --network=hexaa-test dmfenton/wait smtp:1025 -t 120
# - docker run --network=hexaa-test dmfenton/wait smtp:8025 -t 120
# - docker run --network=hexaa-test dmfenton/wait web:80 -t 120
# - docker exec -t frontend sh -c '/opt/hexaa-frontend/vendor/bin/behat -c /opt/hexaa-frontend/behat.yml -n --tags service'
# tags:
# - dind
#
#test-profile:
# stage: test
# script:
# - docker network create hexaa-test
# - docker run --network=hexaa-test -d --name db -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_USER=someuser -e MYSQL_PASSWORD=somepass -e MYSQL_DATABASE=hexaa -v /builds/hexaa/hexaa-frontend/docker-prod/mysql_test_data_dump.sql:/docker-entrypoint-initdb.d/01-test_data.sql mariadb:10.2
# - docker run --network=hexaa-test -d --name memcached memcached
# - docker run --network=hexaa-test -d --name grid -e USE_SELENIUM=2 elgalu/selenium:3.2.0-p4
# - docker run --network=hexaa-test -d --name smtp mailhog/mailhog
# - docker run --network=hexaa-test -d --name frontend -v hexaa_ui_source:/opt/hexaa-frontend -e HEXAA_FRONTEND_API_BASE_URL="http://web/backend/api/" -e HEXAA_FRONTEND_MAILER_PORT=1025 $CONTAINER_TEST_IMAGE
# - docker run --network=hexaa-test dmfenton/wait db:3306 -t 120
# - docker run --network=hexaa-test -d --name backend -v hexaa_backend_source:/opt/hexaa-backend -v /builds/hexaa/hexaa-frontend/docker-prod/hexaa_entityids.yml:/opt/hexaa-backend/app/config/hexaa_entityids.yml -e HEXAA_BACKEND_DATABASE_USER=someuser -e HEXAA_BACKEND_DATABASE_PASSWORD=somepass -e [email protected] hexaaproject/hexaa-backend:new-api-dev
# - docker run --network=hexaa-test -d --name web -v hexaa_ui_source:/opt/hexaa-frontend -v hexaa_backend_source:/opt/hexaa-backend -v /builds/hexaa/hexaa-frontend/docker-prod/default-hexaa-fakeshib.conf:/etc/apache2/sites-enabled/000-default.conf -e APACHE_SHIB_APACHE_MODULES_TO_START="rewrite proxy proxy_fcgi" -e APACHE_SHIB_APACHE_START_SHIB=false solazs/apache-shib
# - docker run --network=hexaa-test dmfenton/wait grid:24444 -t 120
# - docker run --network=hexaa-test dmfenton/wait smtp:1025 -t 120
# - docker run --network=hexaa-test dmfenton/wait smtp:8025 -t 120
# - docker run --network=hexaa-test dmfenton/wait web:80 -t 120
# - docker exec -t frontend sh -c '/opt/hexaa-frontend/vendor/bin/behat -c /opt/hexaa-frontend/behat.yml -n --tags profile'
# tags:
# - dind
#
#test-admin:
# stage: test
# script:
# - docker network create hexaa-test
# - docker run --network=hexaa-test -d --name db -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_USER=someuser -e MYSQL_PASSWORD=somepass -e MYSQL_DATABASE=hexaa -v /builds/hexaa/hexaa-frontend/docker-prod/mysql_test_data_dump.sql:/docker-entrypoint-initdb.d/01-test_data.sql mariadb:10.2
# - docker run --network=hexaa-test -d --name memcached memcached
# - docker run --network=hexaa-test -d --name grid -e USE_SELENIUM=2 elgalu/selenium:3.2.0-p4
# - docker run --network=hexaa-test -d --name smtp mailhog/mailhog
# - docker run --network=hexaa-test -d --name frontend -v hexaa_ui_source:/opt/hexaa-frontend -e HEXAA_FRONTEND_API_BASE_URL="http://web/backend/api/" -e HEXAA_FRONTEND_MAILER_PORT=1025 $CONTAINER_TEST_IMAGE
# - docker run --network=hexaa-test dmfenton/wait db:3306 -t 120
# - docker run --network=hexaa-test -d --name backend -v hexaa_backend_source:/opt/hexaa-backend -v /builds/hexaa/hexaa-frontend/docker-prod/hexaa_entityids.yml:/opt/hexaa-backend/app/config/hexaa_entityids.yml -e HEXAA_BACKEND_DATABASE_USER=someuser -e HEXAA_BACKEND_DATABASE_PASSWORD=somepass -e [email protected] hexaaproject/hexaa-backend:new-api-dev
# - docker run --network=hexaa-test -d --name web -v hexaa_ui_source:/opt/hexaa-frontend -v hexaa_backend_source:/opt/hexaa-backend -v /builds/hexaa/hexaa-frontend/docker-prod/default-hexaa-fakeshib.conf:/etc/apache2/sites-enabled/000-default.conf -e APACHE_SHIB_APACHE_MODULES_TO_START="rewrite proxy proxy_fcgi" -e APACHE_SHIB_APACHE_START_SHIB=false solazs/apache-shib
# - docker run --network=hexaa-test dmfenton/wait grid:24444 -t 120
# - docker run --network=hexaa-test dmfenton/wait smtp:1025 -t 120
# - docker run --network=hexaa-test dmfenton/wait smtp:8025 -t 120
# - docker run --network=hexaa-test dmfenton/wait web:80 -t 120
# - docker exec -t frontend sh -c '/opt/hexaa-frontend/vendor/bin/behat -c /opt/hexaa-frontend/behat.yml -n --tags admin'
# tags:
# - dind
#test-organization:
# stage: test
# script:
# - docker network create hexaa-test
# - docker run --network=hexaa-test -d --name db -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_USER=someuser -e MYSQL_PASSWORD=somepass -e MYSQL_DATABASE=hexaa mysql
# - docker run --network=hexaa-test -d --name memcached memcached
# - docker run --network=hexaa-test -d --name grid -e USE_SELENIUM=2 elgalu/selenium:3.2.0-p4
# - docker run --network=hexaa-test -d --name smtp mailhog/mailhog
# - docker run --network=hexaa-test -d --name project.local $CONTAINER_TEST_IMAGE
# - docker run --network=hexaa-test -d --name hexaa-test-data-manager hexaaproject/hexaa-test-data-manager:for-dev
# - docker run --network=hexaa-test dmfenton/wait db:3306 -t 120
# - docker run --network=hexaa-test -d --name hexaa-backend hexaaproject/hexaa-backend:for-dev
# - docker run --network=hexaa-test dmfenton/wait hexaa-backend:80 -t 120
# - docker run --network=hexaa-test dmfenton/wait project.local:443 -t 120
# - docker exec -t project.local sh -c '/var/www/project/vendor/bin/behat -c /var/www/project/behat.yml -n --tags reset,organization'
# tags:
# - dind
# except:
# - staging
#test-service:
# stage: test
# script:
# - docker network create hexaa-test
# - docker run --network=hexaa-test -d --name db -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_USER=someuser -e MYSQL_PASSWORD=somepass -e MYSQL_DATABASE=hexaa mysql
# - docker run --network=hexaa-test -d --name memcached memcached
# - docker run --network=hexaa-test -d --name grid -e USE_SELENIUM=2 elgalu/selenium:3.2.0-p4
# - docker run --network=hexaa-test -d --name smtp mailhog/mailhog
# - docker run --network=hexaa-test -d --name project.local $CONTAINER_TEST_IMAGE
# - docker run --network=hexaa-test -d --name hexaa-test-data-manager hexaaproject/hexaa-test-data-manager:for-dev
# - docker run --network=hexaa-test dmfenton/wait db:3306 -t 120
# - docker run --network=hexaa-test -d --name hexaa-backend hexaaproject/hexaa-backend:for-dev
# - docker run --network=hexaa-test dmfenton/wait hexaa-backend:80 -t 120
# - docker run --network=hexaa-test dmfenton/wait project.local:443 -t 120
# - docker exec -t project.local sh -c '/var/www/project/vendor/bin/behat -c /var/www/project/behat.yml -n --tags reset,service'
# tags:
# - dind
# except:
# - staging
#
#test-profile:
# stage: test
# script:
# - docker network create hexaa-test
# - docker run --network=hexaa-test -d --name db -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_USER=someuser -e MYSQL_PASSWORD=somepass -e MYSQL_DATABASE=hexaa mysql
# - docker run --network=hexaa-test -d --name memcached memcached
# - docker run --network=hexaa-test -d --name grid -e USE_SELENIUM=2 elgalu/selenium:3.2.0-p4
# - docker run --network=hexaa-test -d --name smtp mailhog/mailhog
# - docker run --network=hexaa-test -d --name project.local $CONTAINER_TEST_IMAGE
# - docker run --network=hexaa-test -d --name hexaa-test-data-manager hexaaproject/hexaa-test-data-manager:for-dev
# - docker run --network=hexaa-test dmfenton/wait db:3306 -t 120
# - docker run --network=hexaa-test -d --name hexaa-backend hexaaproject/hexaa-backend:for-dev
# - docker run --network=hexaa-test dmfenton/wait hexaa-backend:80 -t 120
# - docker run --network=hexaa-test dmfenton/wait project.local:443 -t 120
# - docker exec -t project.local sh -c '/var/www/project/vendor/bin/behat -c /var/www/project/behat.yml -n --tags reset,profile'
# tags:
# - dind
# except:
# - staging
#
#test-admin:
# stage: test
# script:
# - docker network create hexaa-test
# - docker run --network=hexaa-test -d --name db -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_USER=someuser -e MYSQL_PASSWORD=somepass -e MYSQL_DATABASE=hexaa mysql
# - docker run --network=hexaa-test -d --name memcached memcached
# - docker run --network=hexaa-test -d --name grid -e USE_SELENIUM=2 elgalu/selenium:3.2.0-p4
# - docker run --network=hexaa-test -d --name smtp mailhog/mailhog
# - docker run --network=hexaa-test -d --name project.local $CONTAINER_TEST_IMAGE
# - docker run --network=hexaa-test -d --name hexaa-test-data-manager hexaaproject/hexaa-test-data-manager:for-dev
# - docker run --network=hexaa-test dmfenton/wait db:3306 -t 120
# - docker run --network=hexaa-test -d --name hexaa-backend hexaaproject/hexaa-backend:for-dev
# - docker run --network=hexaa-test dmfenton/wait hexaa-backend:80 -t 120
# - docker run --network=hexaa-test dmfenton/wait project.local:443 -t 120
# - docker exec -t project.local sh -c '/var/www/project/vendor/bin/behat -c /var/www/project/behat.yml -n --tags reset,admin'
# tags:
# - dind
# except:
# - staging
release_stable:
stage: release
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_STABLE_IMAGE
- docker push $CONTAINER_STABLE_IMAGE
# log in to hub.docker.com
- docker login -u $DOCKERHUB_REGISTRY_USER -p $DOCKERHUB_REGISTRY_PASS
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_STABLE_RELEASE_IMAGE
- docker push $CONTAINER_STABLE_RELEASE_IMAGE
only:
- master
tags:
- dind
release_staging:
stage: release
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_STAGING_RELEASE_IMAGE
# log in to hub.docker.com
- docker login -u $DOCKERHUB_REGISTRY_USER -p $DOCKERHUB_REGISTRY_PASS
- docker push $CONTAINER_STAGING_RELEASE_IMAGE
only:
- staging
tags:
- dind
deploy_to_staging:
stage: deploy
script:
- echo TODO
#- ssh -A gitlab@$DEPLOY_STAGING_TARGET "docker login -u $REGISTRY_USER -p $REGISTRY_PASS $REGISTRY_ADDR; docker pull $CONTAINER_STAGING_RELEASE_IMAGE; cd /opt/hexaa; docker-compose down; docker volume rm hexaa_hexaa_ui_source; docker-compose up -d;"
only:
- staging
tags:
- dind
trigger_deploy:
stage: deploy
script:
- $HEXAA_GROUP_DEPLOY_TRIGGER