-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
104 lines (96 loc) · 2.74 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
image: docker:stable
stages:
- build
- test
- deploy
variables:
IMAGE: ${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}
build:users:
stage: build
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
script:
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull $IMAGE:users || true
- docker build
--cache-from $IMAGE:users
--tag $IMAGE:users
--file ./services/users/Dockerfile.prod
--build-arg SECRET_KEY=$SECRET_KEY
"./services/users"
- docker push $IMAGE:users
build:client:
stage: build
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
REACT_APP_USERS_SERVICE_URL: http://localhost:5001
script:
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull $IMAGE:client || true
- docker build
--cache-from $IMAGE:client
--tag $IMAGE:client
--file ./services/client/Dockerfile.ci
"./services/client"
- docker push $IMAGE:client
test:users:
stage: test
image: $IMAGE:users
services:
- postgres:latest
variables:
POSTGRES_DB: users
POSTGRES_USER: runner
POSTGRES_PASSWORD: runner
DATABASE_TEST_URL: postgres://runner:runner@postgres:5432/users
FLASK_ENV: development
script:
- cd /usr/src/app
- pip install -r requirements-dev.txt
- python -m pytest "project/tests" -p no:warnings
- python -m flake8 project
- python -m black project --check
- python -m isort project/**/*.py --check-only
test:client:
stage: test
image: $IMAGE:client
script:
- cd /usr/src/app
- npm run prettier:check
- npm run lint
- npm run test
deploy:heroku:
stage: deploy
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
HEROKU_APP_NAME: rocky-gorge-32182
HEROKU_REGISTRY_IMAGE: registry.heroku.com/${HEROKU_APP_NAME}/web
script:
- apk add --no-cache curl
- chmod +x ./release.sh
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull $IMAGE:build-react || true
- docker pull $IMAGE:production || true
- docker build
--target build-react
--cache-from $IMAGE:build-react
--tag $IMAGE:build-react
--file ./Dockerfile.deploy
"."
- docker build
--cache-from $IMAGE:production
--tag $IMAGE:production
--tag $HEROKU_REGISTRY_IMAGE
--file ./Dockerfile.deploy
"."
- docker push $IMAGE:build-react
- docker push $IMAGE:production
- docker login -u _ -p $HEROKU_AUTH_TOKEN registry.heroku.com
- docker push $HEROKU_REGISTRY_IMAGE
- ./release.sh