-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
87 lines (74 loc) · 2.71 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
---
image: docker:17.09-git
services:
- docker:17.09-dind
stages:
- build
- test
- deploy
variables:
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
test:
stage: test
script:
- docker run --rm -v $PWD:/app -w /app node:8 npm install
# Test basic application build first
- docker run --rm -v $PWD:/app -w /app node:8 ./node_modules/.bin/ng build --prod --environment=homolog --output-path dist/empurrandojuntos --deploy-url /
# Now, proceed with regular automated testing
- docker run --rm -v $PWD:/app -w /app node:8 ./node_modules/.bin/ng test --code-coverage --single-run
tags:
- docker
build to homolog:
stage: build
script:
- docker run --rm -v $PWD:/app -w /app node:8 npm install
- docker run --rm -v $PWD:/app -w /app node:8 ./node_modules/.bin/ng build --prod --environment=homolog --output-path dist/empurrandojuntos --deploy-url /
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker create --name frontend nginx
- docker cp dist/empurrandojuntos/. frontend:/usr/share/nginx/html/
- docker cp compose/production/nginx/default.conf frontend:/etc/nginx/conf.d/default.conf
- docker commit frontend $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
- docker push $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
environment: homolog
tags:
- docker
only:
- master
build to production:
stage: build
script:
- docker run --rm -v $PWD:/app -w /app node:8 npm install
- docker run --rm -v $PWD:/app -w /app node:8 ./node_modules/.bin/ng build --prod --environment=prod --output-path dist/empurrandojuntos --deploy-url /
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker create --name frontend nginx
- docker cp dist/empurrandojuntos/. frontend:/usr/share/nginx/html/
- docker cp compose/production/nginx/default.conf frontend:/etc/nginx/conf.d/default.conf
- docker commit frontend $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
- docker tag $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
- docker push $CI_REGISTRY_IMAGE:latest
environment: production
tags:
- docker
only:
- tags
deploy to homolog:
stage: deploy
image: cdrx/rancher-gitlab-deploy
script:
- upgrade --environment FPAbramo --stack brasilqueopovoquer-empurrandojuntos-dev --service frontend --no-finish-upgrade
environment: homolog
tags:
- docker
only:
- master
deploy to production:
stage: deploy
image: cdrx/rancher-gitlab-deploy
script:
- upgrade --environment FPAbramo --stack empurrandojuntos-prod --service frontend --no-finish-upgrade
environment: production
tags:
- docker
only:
- tags