-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
executable file
·163 lines (154 loc) · 4.99 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
stages:
- build
- push
- audit
- deploy
- cleanup
variables:
PROJECT_NAME: kinder-pigiama-party-2019
build:
stage: build
image: registry.caffeina.co/open-source/docker-gitlab-ci:latest
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker-compose -f ./docker/build.yml build --build-arg CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME
only:
- master
- alpha
- beta
push:
stage: push
image: registry.caffeina.co/open-source/docker-gitlab-ci:latest
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker-compose -f ./docker/build.yml push
only:
- master
- alpha
- beta
frontend:
stage: audit
image: registry.caffeina.co/open-source/docker-gitlab-ci:latest
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- ./cmd/compose.sh run --entrypoint npm frontend_server audit
allow_failure: true
only:
- master
deploy-n2:
stage: deploy
image: registry.caffeina.co/open-source/docker-gitlab-ci:latest
variables:
DOCKER_TLS_VERIFY: "1"
DOCKER_HOST: ${N2_DOCKER_HOST}
DOCKER_CERT_PATH: ${N2_DOCKER_CERT_PATH}
VIRTUAL_HOST: "${CI_COMMIT_REF_NAME}.${CI_PROJECT_NAME}.${DOCKER_MACHINE_NAME}"
COMPOSE_PROJECT_NAME: ${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}
DC_FILE: "docker-compose.yml"
script:
# Env
- printenv $(echo "n2_env") > ./.env
# Certs
- mkdir -p ${DOCKER_CERT_PATH}
- echo "${N2_DOCKER_MACHINE_CA}" > ${DOCKER_CERT_PATH}/ca.pem
- echo "${N2_DOCKER_CLIENT_CERT}" > ${DOCKER_CERT_PATH}/cert.pem
- echo "${N2_DOCKER_CLIENT_KEY}" > ${DOCKER_CERT_PATH}/key.pem
# Deploy
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker-compose -f ${DC_FILE} pull
- docker-compose -f ${DC_FILE} up -d --remove-orphans
# Cleanup
- rm -rf ${DOCKER_CERT_PATH}
environment:
name: ${CI_COMMIT_REF_NAME}
url: "http://${CI_COMMIT_REF_NAME}.${CI_PROJECT_NAME}.${DOCKER_MACHINE_NAME}/"
when: manual
only:
- master
- alpha
- beta
deploy-n3:
stage: deploy
image: registry.caffeina.co/open-source/docker-gitlab-ci:latest
variables:
DOCKER_TLS_VERIFY: "1"
DOCKER_HOST: ${N3_DOCKER_HOST}
DOCKER_CERT_PATH: ${N3_DOCKER_CERT_PATH}
VIRTUAL_HOST: "${CI_COMMIT_REF_NAME}.${CI_PROJECT_NAME}.${N3_DOCKER_MACHINE_NAME}"
COMPOSE_PROJECT_NAME: ${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}
DC_FILE: "docker-compose.yml"
script:
# Env
- printenv $(echo "n3_env") > ./.env
# Certs
- mkdir -p ${DOCKER_CERT_PATH}
- echo "${N3_DOCKER_MACHINE_CA}" > ${DOCKER_CERT_PATH}/ca.pem
- echo "${N3_DOCKER_CLIENT_CERT}" > ${DOCKER_CERT_PATH}/cert.pem
- echo "${N3_DOCKER_CLIENT_KEY}" > ${DOCKER_CERT_PATH}/key.pem
# Deploy
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker-compose -f ${DC_FILE} pull
- docker-compose -f ${DC_FILE} up -d --remove-orphans
# Cleanup
- rm -rf ${DOCKER_CERT_PATH}
environment:
name: ${CI_COMMIT_REF_NAME}
url: "http://${CI_COMMIT_REF_NAME}.${CI_PROJECT_NAME}.${N3_DOCKER_MACHINE_NAME}/"
#when: manual
only:
- master
- alpha
- beta
n2-wipe-data-and-stop:
stage: cleanup
image: registry.caffeina.co/open-source/docker-gitlab-ci:latest
variables:
DOCKER_TLS_VERIFY: "1"
DOCKER_HOST: ${N2_DOCKER_HOST}
DOCKER_CERT_PATH: ${N2_DOCKER_CERT_PATH}
VIRTUAL_HOST: "${CI_COMMIT_REF_NAME}.${CI_PROJECT_NAME}.${DOCKER_MACHINE_NAME}"
COMPOSE_PROJECT_NAME: ${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}
DC_FILE: "docker-compose.yml"
script:
# Certs
- mkdir -p ${DOCKER_CERT_PATH}
- echo "${N2_DOCKER_MACHINE_CA}" > ${DOCKER_CERT_PATH}/ca.pem
- echo "${N2_DOCKER_CLIENT_CERT}" > ${DOCKER_CERT_PATH}/cert.pem
- echo "${N2_DOCKER_CLIENT_KEY}" > ${DOCKER_CERT_PATH}/key.pem
# STOP
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker-compose -f ${DC_FILE} down -v
# Cleanup
- rm -rf ${DOCKER_CERT_PATH}
when: manual
environment:
name: ${CI_COMMIT_REF_NAME}
action: stop
n3-wipe-data-and-stop:
stage: cleanup
image: registry.caffeina.co/open-source/docker-gitlab-ci:latest
variables:
DOCKER_TLS_VERIFY: "1"
DOCKER_HOST: ${N3_DOCKER_HOST}
DOCKER_CERT_PATH: ${N3_DOCKER_CERT_PATH}
VIRTUAL_HOST: "${CI_COMMIT_REF_NAME}.${CI_PROJECT_NAME}.${DOCKER_MACHINE_NAME}"
COMPOSE_PROJECT_NAME: ${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}
DC_FILE: "docker-compose.yml"
script:
# Certs
- mkdir -p ${DOCKER_CERT_PATH}
- echo "${N3_DOCKER_MACHINE_CA}" > ${DOCKER_CERT_PATH}/ca.pem
- echo "${N3_DOCKER_CLIENT_CERT}" > ${DOCKER_CERT_PATH}/cert.pem
- echo "${N3_DOCKER_CLIENT_KEY}" > ${DOCKER_CERT_PATH}/key.pem
# STOP
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker-compose -f ${DC_FILE} down -v
# Cleanup
- rm -rf ${DOCKER_CERT_PATH}
when: manual
environment:
name: ${CI_COMMIT_REF_NAME}
action: stop