-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml.sample
97 lines (74 loc) · 2.15 KB
/
.gitlab-ci.yml.sample
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
# defining all stages
stages:
- test
- build
- deploy
# testing stage
Test:
# defining the stage name
stage: test
# only on prod mode
only:
refs:
- prod
# defining specific runners
# tags:
# - my-runner
# defining the base image
image: hub.hamdocker.ir/library/python:3.9-slim-buster
# defining the services which it depends on
services:
- name: hub.hamdocker.ir/library/postgres:alpine
alias: db
# scripts which needs to be run before main script
before_script:
- pip3 install -r requirements.txt
- cd ./core
- python manage.py migrate
- python manage.py check
# main script for testing django app
script:
- export DJANGO_SETTINGS_MODULE=core.settings
- pytest .
# variables for service and main image
variables:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# building stage
darkube_build:
# name of the stage
stage: build
# using darkube image cli
image: hamravesh.hamdocker.ir/public/darkube-cli:v1.1
# only doing the job in prod mode
only:
refs:
- stage
# defining specific runners
# tags:
# - my-runner
# running build script for the project
# name of the predefined env variables: https://github.com/gitlabhq/gitlabhq/blob/master/doc/ci/variables/predefined_variables.md
script:
- 'darkube build --push -t $IMAGE:$CI_COMMIT_SHORT_SHA -t $IMAGE:$CI_COMMIT_REF_SLUG --workdir
. --file ./dockerfiles/prod/django/Dockerfile --build-context . '
# deployment stage
darkube_deploy:
# name of the stage
stage: deploy
# using darkube image cli
image: hamravesh.hamdocker.ir/public/darkube-cli:v1.1
# only doing the job in prod mode
only:
refs:
- prod
# defining specific runners
# tags:
# - my-runner
# running deploy script for the project
# name of the predefined env variables: https://github.com/gitlabhq/gitlabhq/blob/master/doc/ci/variables/predefined_variables.md
script:
- darkube deploy --ref prod --token ${DARKUBE_DEPLOY_TOKEN} --app-id
${DARKUBE_APP_ID} --image-tag "${CI_COMMIT_SHORT_SHA}" --job-id
"${CI_JOB_ID}" --stateless-app true