-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
99 lines (79 loc) · 2.4 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
stages:
- build
- docker
- deploy
build_job:
stage: build
image: valentineus/meteor:build-1.6
only:
- dev
- dev-ci
- master
tags:
- docker
artifacts:
paths:
- build
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- node_modules
variables:
METEOR_ALLOW_SUPERUSER: "true"
TOOL_NODE_FLAGS: "--max_old_space_size=4096"
before_script:
- apt-get update
- apt-get --no-install-recommends --no-install-suggests --yes install procps
- git submodule sync --recursive
- git submodule update --init --recursive
- meteor npm install
- meteor reset
script:
- meteor build --directory ./build-source --architecture "os.linux.x86_64"
- mv ./build-source/bundle ./build
- cd ./build/programs/server
- meteor npm install
docker_job:
stage: docker
image: docker:stable
services:
- docker:dind
only:
- dev
- dev-ci
- master
tags:
- docker
artifacts:
paths:
- build
before_script:
- docker login --username "$(printenv GITLAB_USERNAME)" --password "$(printenv GITLAB_PASSWORD)" registry.styleschool.ru
script:
- docker build --tag "$(printenv GITLAB_REPOSITORY):$(printenv CI_COMMIT_REF_SLUG)" ./
- docker push "$(printenv GITLAB_REPOSITORY):$(printenv CI_COMMIT_REF_SLUG)"
deploy_job:
stage: deploy
only:
- dev
- dev-ci
- master
tags:
- hetzner
before_script:
- docker rm --force "$(printenv CONTAINER_NAME)_$(printenv CI_COMMIT_REF_SLUG)"
- docker login --username "$(printenv GITLAB_USERNAME)" --password "$(printenv GITLAB_PASSWORD)" registry.styleschool.ru
script:
- docker pull "$(printenv GITLAB_REPOSITORY):$(printenv CI_COMMIT_REF_SLUG)"
- docker run --detach
--env "GITLAB_PROFILE_TOKEN=$(printenv GITLAB_PROFILE_TOKEN)"
--env "GITLAB_PROFILE_URL=$(printenv GITLAB_PROFILE_URL)"
--env "MAIL_URL=$(printenv MAIL_URL)"
--env "MONGO_URL=$(printenv MONGO_URL_$(printenv CI_COMMIT_REF_SLUG))"
--env "ROOT_URL=$(printenv ROOT_URL_$(printenv CI_COMMIT_REF_SLUG))"
--env "TOKEN=$(printenv TOKEN_KEY)"
--name "$(printenv CONTAINER_NAME)_$(printenv CI_COMMIT_REF_SLUG)"
--publish $(printenv PORT_$(printenv CI_COMMIT_REF_SLUG)):3000
--restart=always
--volume "$(printenv LOG)$(printenv CI_COMMIT_REF_SLUG):/var/log/app"
"$(printenv GITLAB_REPOSITORY):$(printenv CI_COMMIT_REF_SLUG)"