-
Notifications
You must be signed in to change notification settings - Fork 65
/
.gitlab-ci.yml
155 lines (145 loc) · 4.73 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
stages:
- test
- docs
- build
- docker
- deploy
variables:
POSTGRES_DB: neoscan_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: "postgres"
before_script:
- export IMAGE_TAG="$CI_PIPELINE_ID-$CI_COMMIT_REF_SLUG"
- export SYNC_REGISTRY_PATH="$CI_REGISTRY_IMAGE/sync:$IMAGE_TAG"
- export API_REGISTRY_PATH="$CI_REGISTRY_IMAGE/api:$IMAGE_TAG"
- export FULL_REGISTRY_PATH="$CI_REGISTRY_IMAGE/full:$IMAGE_TAG"
test:
stage: test
image: bitwalker/alpine-elixir-phoenix:1.7.3
services:
- postgres
cache:
key: test-cache
paths:
- deps/
- _build/
script:
- mix local.rebar --force
- mix local.hex --force
- mix deps.get
- mix format --check-formatted
- MIX_ENV=test mix do compile --warnings-as-errors, coveralls.json
- bash <(curl -s https://codecov.io/bash)
- rm -Rf _build/test/lib/neo*
artifacts:
paths:
- apps/neoscan_web/assets/static/docs/api.apib
docs:
stage: docs
image:
name: humangeo/aglio
entrypoint: [""]
script:
- aglio --theme-variables streak --theme-template triple -i apps/neoscan_web/assets/static/docs/api.apib -o apps/neoscan_web/assets/static/docs/index.html
artifacts:
paths:
- apps/neoscan_web/assets/static/docs/index.html
build:
stage: build
image: bitwalker/alpine-elixir-phoenix:1.7.3
cache:
key: build-cache
paths:
- deps/
- _build/
variables:
MIX_ENV: prod
script:
- mix local.rebar --force
- mix local.hex --force
- mix deps.get
- cd apps/neoscan_web/assets && npm install && npm run deploy
- cd ../../.. && mix compile
- mix phx.digest
- mix release --name=neoscan_sync --env=prod
- mix release --name=neoscan_api --env=prod
- mix release --name=neoscan_full --env=prod
- mkdir -p export/neoscan_sync && mkdir -p export/neoscan_api && mkdir -p export/neoscan_full
- RELEASE_DIR=`ls -d _build/prod/rel/neoscan_sync/releases/*/` && tar -xf "$RELEASE_DIR/neoscan_sync.tar.gz" -C export/neoscan_sync/
- RELEASE_DIR=`ls -d _build/prod/rel/neoscan_api/releases/*/` && tar -xf "$RELEASE_DIR/neoscan_api.tar.gz" -C export/neoscan_api/
- RELEASE_DIR=`ls -d _build/prod/rel/neoscan_full/releases/*/` && tar -xf "$RELEASE_DIR/neoscan_full.tar.gz" -C export/neoscan_full/
- rm -Rf _build/prod/lib/neo*
artifacts:
paths:
- export
docker:
stage: docker
image: docker:latest
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker build --build-arg APP=neoscan_sync -t $SYNC_REGISTRY_PATH .
- docker build --build-arg APP=neoscan_api -t $API_REGISTRY_PATH .
- docker build --build-arg APP=neoscan_full -t $FULL_REGISTRY_PATH .
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker push $SYNC_REGISTRY_PATH
- docker push $API_REGISTRY_PATH
- docker push $FULL_REGISTRY_PATH
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker tag $SYNC_REGISTRY_PATH $CI_REGISTRY_IMAGE/sync || true"
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker tag $API_REGISTRY_PATH $CI_REGISTRY_IMAGE/api || true"
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker tag $FULL_REGISTRY_PATH $CI_REGISTRY_IMAGE/full || true"
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker push $CI_REGISTRY_IMAGE/sync || true"
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker push $CI_REGISTRY_IMAGE/api || true"
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker push $CI_REGISTRY_IMAGE/full || true"
- docker login -u $NEOSCAN_DOCKER_USER -p "$NEOSCAN_DOCKER_PASSWORD"
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker tag $FULL_REGISTRY_PATH cityofzion/neoscan || true"
- "[ \"$CI_COMMIT_REF_SLUG\" == \"master\" ] && docker push cityofzion/neoscan || true"
staging:
stage: deploy
image:
name: lachlanevenson/k8s-kubectl
entrypoint: [""]
environment: staging
script:
- mkdir ~/.kube && echo "${STAGING_KUB_CONFIG}" > ~/.kube/config
- ./deploy
variables:
STAGING: "true"
when: manual
staging-network:
stage: deploy
image:
name: lachlanevenson/k8s-kubectl
entrypoint: [""]
script:
- mkdir ~/.kube && echo "${STAGING_KUB_CONFIG}" > ~/.kube/config
- ./deploy-network
variables:
STAGING: "true"
when: manual
production:
stage: deploy
image:
name: lachlanevenson/k8s-kubectl
entrypoint: [""]
environment: production
script:
- mkdir ~/.kube && echo "${PROD3_KUB_CONFIG}" > ~/.kube/config
- ./deploy
only:
- master
- optimize_insert3
when: manual
production-newtork:
stage: deploy
image:
name: lachlanevenson/k8s-kubectl
entrypoint: [""]
script:
- mkdir ~/.kube && echo "${PROD3_KUB_CONFIG}" > ~/.kube/config
- ./deploy-network
only:
- master
- optimize_insert3
when: manual