-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gitlab-ci.yml
80 lines (75 loc) · 1.86 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
#ENV variables: https://docs.gitlab.com/ce/ci/variables/
image: karser/docker-compose-ci
stages:
- test
- build
- deploy
before_script:
- docker -v && docker-compose -v
test dev:
stage: test
only:
refs:
- branches
variables:
COMPOSE_PROJECT_NAME: "easyquickimport_test${CI_JOB_ID}"
DOCKER_ENV: test
APP_ENV: test
script:
- cd docker
- bin/copy-env.sh
- bin/build.sh
- docker-compose run --rm php sh -c "bin/run-tests.sh"
after_script:
- cd docker
- docker-compose down --remove-orphans
artifacts:
expire_in: 1 week
when: always
paths:
- var/log
build image:
stage: build
variables:
DOCKER_ENV: prod
APP_ENV: prod
script:
- cd docker
- bin/copy-env.sh
- bin/build.sh
- bin/push.sh
deploy prod:
stage: deploy
environment:
name: easyquickimport-prod
url: https://app.easyquickimport.com/
only:
- tags
- branches
when: manual
variables:
DOCKER_ENV: prod
ENVIRONMENT: prod
APP_ENV: prod
COMPOSE_PROJECT_NAME: easyquickimport
VIRTUAL_HOST: app.easyquickimport.com
DATABASE_HOST: ${HZ4_DB_HOST}
MAILER_DSN: ${PROD_MAILER_DSN}
DATABASE_URL: ${PROD_DATABASE_URL}
# connect to the server
DOCKER_TLS_VERIFY: "1"
DOCKER_HOST: $HZ4_DOCKER_HOST
DOCKER_CERT_PATH: "/tmp/certs"
before_script:
- mkdir -p $DOCKER_CERT_PATH
- echo "$HZ4_CA" > $DOCKER_CERT_PATH/ca.pem
- echo "$HZ4_CLIENT_CERT" > $DOCKER_CERT_PATH/cert.pem
- echo "$HZ4_CLIENT_KEY" > $DOCKER_CERT_PATH/key.pem
- ls -alh $DOCKER_CERT_PATH
- echo ${CI_REGISTRY_PASSWORD} | docker login ${CI_REGISTRY} -u ${CI_REGISTRY_USER} --password-stdin
script:
- cd docker
- bin/copy-env.sh
- docker-compose config | docker stack deploy --with-registry-auth -c - ${COMPOSE_PROJECT_NAME}
after_script:
- rm -rf $DOCKER_CERT_PATH