-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
243 lines (228 loc) · 10.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
image: $CI_REGISTRY_IMAGE/env:latest
stages:
- check
- build
- test
- deploy
services:
- docker:20.10-dind
python:
stage: check
before_script:
- ./manage.sh update_dev_packages
script:
- make test.pep8
- make test.pylint
build:web:
stage: build
before_script:
- ./manage.sh npm_packages
- ./manage.sh update_dev_packages
script:
- ./manage.sh locales
- make V=1 themes.eelo
.build:docker:
stage: build
image: docker:git
tags:
- generic_privileged
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build -t $CI_REGISTRY_IMAGE .
- docker push $CI_REGISTRY_IMAGE
- docker build -t $CI_REGISTRY_IMAGE/nginx -f nginx.Dockerfile .
- docker push $CI_REGISTRY_IMAGE/nginx
build:docker:master:
extends: .build:docker
only:
- master
build:docker:tags:
extends: .build:docker
script:
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
- docker build -t $CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_SLUG -f nginx.Dockerfile .
- docker push $CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_SLUG
only:
- tags
test:unit:
stage: test
before_script:
- ./manage.sh update_dev_packages
script:
- make test.coverage
coverage: '/TOTAL.*\s+(\d+%)$/'
.deploy:template:
stage: deploy
before_script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_PRIVATE_KEY_ED" > $HOME/.ssh/id_ed25519
- echo "$SSH_PUBKEY_ED" > $HOME/.ssh/id_ed25519.pub
- echo "$SSH_KNOWN_HOSTS" > $HOME/.ssh/known_hosts
- chmod 600 ~/.ssh/id_ed25519
- chmod 644 ~/.ssh/known_hosts ~/.ssh/id_ed25519.pub
- ssh $DOCKER_HOST "cd $PATH_STAGING"
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull registry.gitlab.e.foundation:5000/e/cloud/my-spot/env
deploy:spot.eeo.one.backend1:
extends: .deploy:template
when: manual
only:
- branches
environment:
name: eeo1
url: https://spot.eeo.one
variables:
DOCKER_HOST: ssh://${SSH_USER}@${BACKEND1_HOST}
SPOT_HOSTNAME: spot.eeo.one
SPOT_MORTY_HOSTNAME: proxy.spot.eeo.one
SEARX_MORTY_URL: https://proxy.spot.eeo.one
SEARX_PROXY_HTTP: http://proxy01.ecloud.global:1099
SEARX_PROXY_HTTPS: http://proxy01.ecloud.global:1099
COMPOSE_PROJECT_NAME: staging-spot
SPOT_DOCKER_TAG: ${CI_COMMIT_REF_SLUG}
SPOT_NGINX_DOCKER_TAG: ${CI_COMMIT_REF_SLUG}
WIREGUARD_IP: ${BACKEND1_WG_IP}
INTERNAL_NETWORK_NAME: staging-spot-default
FILTRON_PORT: 8088
MORTY_PORT: 8089
script:
- echo "Deploying to $CI_ENVIRONMENT_NAME ($SSH_USER@$BACKEND1_HOST - $BACKEND1_WG_IP - $WIREGUARD_IP)"
- ssh $SSH_USER@$BACKEND1_HOST "cd /mnt/repo-base/staging-spot && git stash && git pull && rm .env && mv .env.prod .env && rm docker-compose.yml && mv docker-compose.prod.yml docker-compose.yml"
- docker-compose up -d --build
- docker-compose restart filtron
- ssh $SSH_USER@$BACKEND1_HOST "cd /mnt/repo-base/staging-spot
&& sed -i 's/SPOT_HOSTNAME=spot.ecloud.global/SPOT_HOSTNAME=$SPOT_HOSTNAME/g' .env
&& sed -i 's/SPOT_MORTY_HOSTNAME=proxy.spot.ecloud.global/SPOT_MORTY_HOSTNAME=$SPOT_MORTY_HOSTNAME/g' .env
&& sed -i 's/SPOT_DOCKER_TAG=latest/SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG/g' .env
&& sed -i 's/SPOT_NGINX_DOCKER_TAG=latest/SPOT_NGINX_DOCKER_TAG=$SPOT_NGINX_DOCKER_TAG/g' .env
&& sed -i 's/localhost:8089/$SPOT_MORTY_HOSTNAME/g' .env
&& sed -i 's/SECRET2BEREPLACED/$SEARX_SECRET/g' .env
&& sed -i 's/KEY2BEREPLACED/$SEARX_MORTY_KEY/g' .env
&& sed -i 's/proxy01.ecloud.global/proxy01.ecloud.global/g' .env
&& sed -i 's/WIREGUARD_IP=127.0.0.1/WIREGUARD_IP=$WIREGUARD_IP/g' .env
&& sed -i 's/FILTRON_PORT=8088/FILTRON_PORT=$FILTRON_PORT/g' .env
&& sed -i 's/MORTY_PORT=8089/MORTY_PORT=$MORTY_PORT/g' .env
&& sed -i 's/INTERNAL_NETWORK_NAME=default/INTERNAL_NETWORK_NAME=$INTERNAL_NETWORK_NAME/g' .env"
deploy:spot.eeo.one.backend2:
extends: .deploy:template
when: manual
only:
- branches
environment:
name: eeo2
url: https://spot.eeo.one
variables:
DOCKER_HOST: ssh://${SSH_USER}@${BACKEND2_HOST}
SPOT_HOSTNAME: spot.eeo.one
SPOT_MORTY_HOSTNAME: proxy.spot.eeo.one
SEARX_MORTY_URL: https://proxy.spot.eeo.one
SEARX_PROXY_HTTP: http://proxy02.ecloud.global:1099
SEARX_PROXY_HTTPS: http://proxy02.ecloud.global:1099
COMPOSE_PROJECT_NAME: staging-spot
SPOT_DOCKER_TAG: ${CI_COMMIT_REF_SLUG}
SPOT_NGINX_DOCKER_TAG: ${CI_COMMIT_REF_SLUG}
WIREGUARD_IP: ${BACKEND2_WG_IP}
INTERNAL_NETWORK_NAME: staging-spot-default
FILTRON_PORT: 8088
MORTY_PORT: 8089
script:
- echo "Deploying to $CI_ENVIRONMENT_NAME ($SSH_USER@$BACKEND2_HOST - $BACKEND2_WG_IP - $WIREGUARD_IP)"
- ssh $SSH_USER@$BACKEND2_HOST "cd /mnt/repo-base/staging-spot && git stash && git pull && rm .env && mv .env.prod .env && rm docker-compose.yml && mv docker-compose.prod.yml docker-compose.yml"
- docker-compose up -d --build
- docker-compose restart filtron
- ssh $SSH_USER@$BACKEND2_HOST "cd /mnt/repo-base/staging-spot
&& sed -i 's/SPOT_HOSTNAME=spot.ecloud.global/SPOT_HOSTNAME=$SPOT_HOSTNAME/g' .env
&& sed -i 's/SPOT_MORTY_HOSTNAME=proxy.spot.ecloud.global/SPOT_MORTY_HOSTNAME=$SPOT_MORTY_HOSTNAME/g' .env
&& sed -i 's/SPOT_DOCKER_TAG=latest/SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG/g' .env
&& sed -i 's/SPOT_NGINX_DOCKER_TAG=latest/SPOT_NGINX_DOCKER_TAG=$SPOT_NGINX_DOCKER_TAG/g' .env
&& sed -i 's/localhost:8089/$SPOT_MORTY_HOSTNAME/g' .env
&& sed -i 's/SECRET2BEREPLACED/$SEARX_SECRET/g' .env
&& sed -i 's/KEY2BEREPLACED/$SEARX_MORTY_KEY/g' .env
&& sed -i 's/proxy01.ecloud.global/proxy02.ecloud.global/g' .env
&& sed -i 's/WIREGUARD_IP=127.0.0.1/WIREGUARD_IP=$WIREGUARD_IP/g' .env
&& sed -i 's/FILTRON_PORT=8088/FILTRON_PORT=$FILTRON_PORT/g' .env
&& sed -i 's/MORTY_PORT=8089/MORTY_PORT=$MORTY_PORT/g' .env
&& sed -i 's/INTERNAL_NETWORK_NAME=default/INTERNAL_NETWORK_NAME=$INTERNAL_NETWORK_NAME/g' .env"
deploy:spot.ecloud.global.backend1:
extends: .deploy:template
only:
- tags
environment:
name: ecloud1
url: https://spot.ecloud.global
variables:
DOCKER_HOST: ssh://${SSH_USER}@${BACKEND1_HOST}
SPOT_HOSTNAME: spot.ecloud.global
SPOT_MORTY_HOSTNAME: proxy.spot.ecloud.global
SEARX_MORTY_URL: https://proxy.spot.ecloud.global
SEARX_PROXY_HTTP: http://proxy01.ecloud.global:1099
SEARX_PROXY_HTTPS: http://proxy01.ecloud.global:1099
COMPOSE_PROJECT_NAME: production-spot
SPOT_DOCKER_TAG: ${CI_COMMIT_REF_SLUG}
SPOT_NGINX_DOCKER_TAG: ${CI_COMMIT_REF_SLUG}
WIREGUARD_IP: ${BACKEND1_WG_IP}
INTERNAL_NETWORK_NAME: spot-default
FILTRON_PORT: 8098
MORTY_PORT: 8099
script:
- echo "Deploying to $CI_ENVIRONMENT_NAME ($SSH_USER@$BACKEND1_HOST - $BACKEND1_WG_IP - $WIREGUARD_IP)"
- ssh $SSH_USER@$BACKEND1_HOST "cd /mnt/repo-base/production-spot && git stash && git pull && rm .env && mv .env.prod .env && rm docker-compose.yml && mv docker-compose.prod.yml docker-compose.yml"
- docker-compose pull
- docker-compose up -d
- docker-compose restart filtron
- ssh $SSH_USER@$BACKEND1_HOST "cd /mnt/repo-base/production-spot
&& sed -i 's/SPOT_HOSTNAME=spot.ecloud.global/SPOT_HOSTNAME=$SPOT_HOSTNAME/g' .env
&& sed -i 's/SPOT_MORTY_HOSTNAME=proxy.spot.ecloud.global/SPOT_MORTY_HOSTNAME=$SPOT_MORTY_HOSTNAME/g' .env
&& sed -i 's/SPOT_DOCKER_TAG=latest/SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG/g' .env
&& sed -i 's/SPOT_NGINX_DOCKER_TAG=latest/SPOT_NGINX_DOCKER_TAG=$SPOT_NGINX_DOCKER_TAG/g' .env
&& sed -i 's/localhost:8089/$SPOT_MORTY_HOSTNAME/g' .env
&& sed -i 's/SECRET2BEREPLACED/$SEARX_SECRET/g' .env
&& sed -i 's/KEY2BEREPLACED/$SEARX_MORTY_KEY/g' .env
&& sed -i 's/proxy01.ecloud.global/proxy01.ecloud.global/g' .env
&& sed -i 's/WIREGUARD_IP=127.0.0.1/WIREGUARD_IP=$WIREGUARD_IP/g' .env
&& sed -i 's/FILTRON_PORT=8088/FILTRON_PORT=$FILTRON_PORT/g' .env
&& sed -i 's/MORTY_PORT=8089/MORTY_PORT=$MORTY_PORT/g' .env
&& sed -i 's/INTERNAL_NETWORK_NAME=default/INTERNAL_NETWORK_NAME=$INTERNAL_NETWORK_NAME/g' .env"
deploy:spot.ecloud.global.backend2:
extends: .deploy:template
only:
- tags
environment:
name: ecloud2
url: https://spot.ecloud.global
variables:
DOCKER_HOST: ssh://${SSH_USER}@${BACKEND2_HOST}
SPOT_HOSTNAME: spot.ecloud.global
SPOT_MORTY_HOSTNAME: proxy.spot.ecloud.global
SEARX_MORTY_URL: https://proxy.spot.ecloud.global
SEARX_PROXY_HTTP: http://proxy02.ecloud.global:1099
SEARX_PROXY_HTTPS: http://proxy02.ecloud.global:1099
COMPOSE_PROJECT_NAME: production-spot
SPOT_DOCKER_TAG: ${CI_COMMIT_REF_SLUG}
SPOT_NGINX_DOCKER_TAG: ${CI_COMMIT_REF_SLUG}
WIREGUARD_IP: ${BACKEND2_WG_IP}
INTERNAL_NETWORK_NAME: spot-default
FILTRON_PORT: 8098
MORTY_PORT: 8099
script:
- echo "Deploying to $CI_ENVIRONMENT_NAME ($SSH_USER@$BACKEND2_HOST - $BACKEND2_WG_IP - $WIREGUARD_IP)"
- ssh $SSH_USER@$BACKEND2_HOST "cd /mnt/repo-base/production-spot && git stash && git pull && rm .env && mv .env.prod .env && rm docker-compose.yml && mv docker-compose.prod.yml docker-compose.yml"
- docker-compose pull
- docker-compose up -d
- docker-compose restart filtron
- ssh $SSH_USER@$BACKEND2_HOST "cd /mnt/repo-base/production-spot
&& sed -i 's/SPOT_HOSTNAME=spot.ecloud.global/SPOT_HOSTNAME=$SPOT_HOSTNAME/g' .env
&& sed -i 's/SPOT_MORTY_HOSTNAME=proxy.spot.ecloud.global/SPOT_MORTY_HOSTNAME=$SPOT_MORTY_HOSTNAME/g' .env
&& sed -i 's/SPOT_DOCKER_TAG=latest/SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG/g' .env
&& sed -i 's/SPOT_NGINX_DOCKER_TAG=latest/SPOT_NGINX_DOCKER_TAG=$SPOT_NGINX_DOCKER_TAG/g' .env
&& sed -i 's/localhost:8089/$SPOT_MORTY_HOSTNAME/g' .env
&& sed -i 's/SECRET2BEREPLACED/$SEARX_SECRET/g' .env
&& sed -i 's/KEY2BEREPLACED/$SEARX_MORTY_KEY/g' .env
&& sed -i 's/proxy01.ecloud.global/proxy02.ecloud.global/g' .env
&& sed -i 's/WIREGUARD_IP=127.0.0.1/WIREGUARD_IP=$WIREGUARD_IP/g' .env
&& sed -i 's/FILTRON_PORT=8088/FILTRON_PORT=$FILTRON_PORT/g' .env
&& sed -i 's/MORTY_PORT=8089/MORTY_PORT=$MORTY_PORT/g' .env
&& sed -i 's/INTERNAL_NETWORK_NAME=default/INTERNAL_NETWORK_NAME=$INTERNAL_NETWORK_NAME/g' .env"