-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
59 lines (56 loc) · 1.73 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
stages:
- build
- push
- deploy
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:
- export TAG=${CI_COMMIT_SHA}
- docker-compose -f docker-compose.build.yml build
- export TAG=latest
- docker-compose -f docker-compose.build.yml build
only:
- tags
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:
- export TAG=${CI_COMMIT_SHA}
- docker-compose -f docker-compose.build.yml push
- export TAG=latest
- docker-compose -f docker-compose.build.yml push
only:
- tags
deploy:
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: "master.${CI_PROJECT_NAME}.${DOCKER_MACHINE_NAME}"
COMPOSE_PROJECT_NAME: ${CI_PROJECT_NAME}_master
DC_FILE: "docker-composes/master.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
# 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: master
url: "http://master.${CI_PROJECT_NAME}.${DOCKER_MACHINE_NAME}/"
#when: manual
only:
- tags