-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci2.yml
96 lines (85 loc) · 2.17 KB
/
.gitlab-ci2.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
image: vasyakrg/docker:latest
stages:
- build
- test
- review
- stage
- production
# variables:
# DATABASE_URL: 'mongodb://mongo/user_posts'
before_script:
- apk update
- apk add openssh-client
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
build_job:
stage: build
before_script:
- echo $REGISTRY_PASSWORD | docker login -u $REGISTRY_USER --password-stdin docker.io
script:
- echo 'Building'
- docker build -t vasyakrg/reddit:$CI_JOB_ID .
- docker tag vasyakrg/reddit:$CI_JOB_ID vasyakrg/reddit:latest
- docker push vasyakrg/reddit:$CI_JOB_ID
- docker push vasyakrg/reddit:latest
test_unit_job:
stage: test
script:
- echo 'Testing 1'
test_unit_job:
stage: test
script:
# - ruby simpletest.rb
- echo 'Testing 2'
- scp docker-compose.yml [email protected]:/home/appuser
- ssh [email protected] "sudo docker-compose up -d"
- ssh [email protected] "sudo docker exec appuser_reddit_1 bash -c 'cd /reddit && ruby simpletest.rb'"
- ssh [email protected] "sudo docker-compose down"
test_integration_job:
stage: test
script:
- echo 'Testing 2'
deploy_dev_job:
stage: review
script:
- echo 'Deploy'
- scp docker-compose.yml [email protected]:/home/appuser
- ssh [email protected] "sudo docker-compose down && sudo docker-compose up -d"
environment:
name: dev
url: http://docker1.aits.life:9292
tags:
- ubuntu
branch review:
stage: review
script: echo "Deploy to $CI_ENVIRONMENT_SLUG"
environment:
name: branch/$CI_COMMIT_REF_NAME
url: http://$CI_ENVIRONMENT_SLUG.example.com
only:
- branches
except:
- master
staging:
stage: stage
when: manual
only:
- /^\d+\.\d+\.\d+/
script:
- echo 'Deploy'
environment:
name: stage
url: https://beta.example.com
production:
stage: production
when: manual
only:
- /^\d+\.\d+\.\d+/
script:
- echo 'Deploy'
environment:
name: production
url: https://example.com