-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
109 lines (97 loc) · 2.51 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
image: docker:latest
variables:
KUBE_DOMAIN: api.flat.k8s.kazik.memleak.pl
stages:
- build-test
- test
- build
- review
- deploy
- deploy-production
- cleanup
build-test:
stage: build-test
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-ci-tests" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-ci-tests"
test:
image: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-ci-tests"
stage: test
services:
- mariadb:10
variables:
MYSQL_DATABASE: flat_test
MYSQL_ROOT_PASSWORD: super_tajne_haslo
script:
- bash scripts/create_ci_test_config
- cd app && python3 manage.py test --noinput
build-master:
stage: build
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
- docker tag "$CI_REGISTRY_IMAGE" "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
only:
- master
build:
stage: build
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except:
- master
deploy-dev:
image: registry.gitlab.memleak.pl:443/flat/flat-api/kubectl
stage: deploy
script:
- command scripts/deployment/deploy
environment:
name: dev
url: http://dev.$KUBE_DOMAIN
variables:
MYSQL_PVC_SIZE: 2Gi
only:
- master
deploy-production:
image: registry.gitlab.memleak.pl:443/flat/flat-api/kubectl
stage: deploy-production
script:
- mkdir -p ~/.kube
- echo $KUBE_PROD_CONFIG | base64 -d > ~/.kube/config
- command scripts/deployment/deploy_prod
environment:
name: production
url: https://api.flat.memleak.pl
when: manual
only:
- master
review:
image: registry.gitlab.memleak.pl:443/flat/flat-api/kubectl
stage: review
script:
- command scripts/deployment/deploy
environment:
name: review/$CI_COMMIT_REF_NAME
url: http://$CI_ENVIRONMENT_SLUG.$KUBE_DOMAIN
on_stop: stop_review
only:
- branches
except:
- master
stop_review:
image: registry.gitlab.memleak.pl:443/flat/flat-api/kubectl
stage: cleanup
script:
- command scripts/deployment/destroy
environment:
name: review/$CI_COMMIT_REF_NAME
action: stop
when: manual
only:
- branches
except:
- master