forked from secfigo/django.nv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
69 lines (63 loc) · 1.81 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
stages:
- build
- test
- release
- preprod
- integration
- prod
build:
stage: build
script:
- virtualenv env
- source env/bin/activate
- pip install -r requirements.txt
- python manage.py check
test:
stage: test
script:
- virtualenv env
- source env/bin/activate
- pip install -r requirements.txt
- python manage.py test taskManager
release:
stage: release
before_script:
- docker version
- docker info
#- docker login -u root -p vagrant@123 gitlab.local:4567
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" gitlab.local:4567
#- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
script:
- docker build -t ${CI_REGISTRY}/root/django.nv:latest --pull .
- docker push ${CI_REGISTRY}/root/django.nv:latest
after_script:
- docker logout ${CI_REGISTRY}
preprod:
stage: preprod
image: gitlab/dind:latest
only:
- "master"
environment: staging
services:
- docker:dind
tags:
- docker
before_script:
- mkdir -p ~/.ssh
- echo "$DEPLOY_SERVER_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- ssh-keyscan -H $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts
script:
- ssh $DEPLOY_USER_NAME@$DEPLOYMENT_SERVER_IP "docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}; docker stop app || true; docker rm app || true; docker pull ${CI_REGISTRY}/root/django.nv:latest; docker run -d -p8000:8000 --name app -d ${CI_REGISTRY}/root/django.nv:latest"
integration:
stage: integration
script:
- echo "This is a integration step"
allow_failure: true # Even if the job fails, continue to next stages
prod:
stage: prod
script:
- echo "This is a deploy step"
when: manual # Continuous Delivery