-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
111 lines (106 loc) · 2.8 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
stages:
- build
- test
- release
- deploy
variables:
FRONT_TEST_IMAGE: registry.gitlab.com/mrokita/covidata.pl:frontend-$CI_BUILD_REF_NAME
FRONT_RELEASE_IMAGE: registry.gitlab.com/mrokita/covidata.pl:frontend-latest
API_TEST_IMAGE: registry.gitlab.com/mrokita/covidata.pl:api-$CI_BUILD_REF_NAME
API_RELEASE_IMAGE: registry.gitlab.com/mrokita/covidata.pl:api-latest
CRAWLER_TEST_IMAGE: registry.gitlab.com/mrokita/covidata.pl:crawler-$CI_BUILD_REF_NAME
CRAWLER_RELEASE_IMAGE: registry.gitlab.com/mrokita/covidata.pl:crawler-latest
SERVICE_TOKEN: ""
SECRET_KEY: ""
DB_PASSWORD: ""
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
build_frontend:
cache:
key: ${CI_COMMIT_REF_SLUG}
only:
refs:
- master
changes:
- "frontend/*"
stage: build
image: docker/compose:alpine-1.25.5
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker info
services:
- docker:dind
tags:
- docker
script:
- export IMAGE_TAG=$CI_BUILD_REF_NAME
- docker-compose build frontend
- docker-compose push frontend
build_api:
stage: build
tags:
- private-shell
script:
- export IMAGE_TAG=$CI_BUILD_REF_NAME
- docker-compose build api
- docker-compose push api
build_crawler:
stage: build
only:
- master
tags:
- private-shell
script:
- export IMAGE_TAG=$CI_BUILD_REF_NAME
- docker-compose build crawler
- docker-compose push crawler
test-api:
stage: test
tags:
- private-shell
script:
- docker run --env DB_PASSWORD=$DB_PASSWORD --env SERVICE_TOKEN=$SERVICE_TOKEN --env SECRET_KEY=$SECRET_KEY $API_TEST_IMAGE sh -c "python -m pytest --cov=. /app/tests/ --cov-report term-missing"
coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
release-frontend-image:
stage: release
tags:
- private-shell
script:
- docker pull $FRONT_TEST_IMAGE
- docker tag $FRONT_TEST_IMAGE $FRONT_RELEASE_IMAGE
- docker push $FRONT_RELEASE_IMAGE
only:
- master
release-api-image:
stage: release
tags:
- private-shell
script:
- docker pull $API_TEST_IMAGE
- docker tag $API_TEST_IMAGE $API_RELEASE_IMAGE
- docker push $API_RELEASE_IMAGE
only:
- master
release-crawler-image:
stage: release
tags:
- private-shell
script:
- docker pull $CRAWLER_TEST_IMAGE
- docker tag $CRAWLER_TEST_IMAGE $CRAWLER_RELEASE_IMAGE
- docker push $CRAWLER_RELEASE_IMAGE
only:
- master
deploy:
stage: deploy
only:
- master
tags:
- private-shell
script:
- export SERVICE_TOKEN=$SERVICE_TOKEN
- export SECRET_KEY=$SECRET_KEY
- export DB_PASSWORD=$DB_PASSWORD
- export IMAGE_TAG=latest
- docker stack deploy --compose-file docker-compose.yml --resolve-image=always --with-registry-auth covidata
when: manual