-
Notifications
You must be signed in to change notification settings - Fork 42
/
.gitlab-ci.yml
93 lines (85 loc) · 2.4 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
image: docker:20.10.16
#image: "docker/compose:1.21.2"
stages:
- build
- test
- deploy
variables:
# When using dind, it's wise to use the overlayfs driver for
# improved performance.
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
CI_REGISTRY: "registry.gitlab.prforge.com"
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker info
build:
stage: build
variables:
NODE_ENV: build
environment:
name: build
image:
name: docker/compose:1.29.2
entrypoint: ["/bin/sh", "-c"]
script:
- echo "CONTAINERS TAG ${CI_COMMIT_SHORT_SHA:-latest}"
#- docker version # verify docker cli is there. Also prints server info
#- docker-compose version # verify the docker-compose cli is there
#- docker-compose -f docker-compose.yml -f docker-compose.build.yml config #checking var substitution
- docker-compose -f docker-compose.yml -f docker-compose.build.yml build
- docker-compose -f docker-compose.yml -f docker-compose.build.yml push
tags:
- builder
test:
stage: test
environment:
name: test
image:
name: docker/compose:1.29.2
entrypoint: ["/bin/sh", "-c"]
variables:
NODE_ENV: test
NETWORK: test
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker info
- echo "Running tests for TAG ${CI_COMMIT_SHORT_SHA:-latest}"
- docker-compose -f docker-compose.yml -f docker-compose.test.yml up --abort-on-container-exit --renew-anon-volumes
tags:
- builder
# - test
deploy_staging:
stage: deploy
script:
- echo "Deploy to staging server"
- docker stack deploy --with-registry-auth -c docker-compose.yml -c docker-compose.staging.yml knests-staging
variables:
NODE_ENV: staging
EXTERNAL_URL: knests-staging.prforge.com
NETWORK: staging
SERVICE_PORT: 8080
environment:
name: staging
only:
- master
tags:
- staging
deploy_prod:
stage: deploy
script:
- echo "Deploy to production server"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker stack deploy --with-registry-auth -c docker-compose.yml -c docker-compose.production.yml knests-production
variables:
NODE_ENV: production
EXTERNAL_URL: knests.prforge.com
NETWORK: production
SERVICE_PORT: 8080
environment:
name: production
when: manual
only:
- master
tags:
- production