-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
47 lines (41 loc) · 1.54 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
image: docker:19.03.5
services:
- docker:19.03.5-dind
stages:
- build
- production
variables:
GKE_CLUSTER_NAME: foobar-cluster
GKE_ZONE: us-east1-d
GKE_PROJECT: foobar
GCP_PROJECT_ID: foobar
PROJECT_NAME: osrm-server-car
IMAGE_NAME: gcr.io/$GCP_PROJECT_ID/$PROJECT_NAME
"Build Docker Image":
stage: build
script:
- mkdir -p /etc/builder
- cat $GCR_SERVICE_ACCOUNT | base64 -d > /etc/builder/sa.json
- docker login -u _json_key -p "$(cat /etc/builder/sa.json)" https://gcr.io
- docker pull $IMAGE_NAME:latest || true
- docker build --cache-from $IMAGE_NAME:latest --tag $IMAGE_NAME:${CI_COMMIT_SHORT_SHA} .
- docker tag $IMAGE_NAME:${CI_COMMIT_SHORT_SHA} $IMAGE_NAME:latest
- docker push $IMAGE_NAME:${CI_COMMIT_SHORT_SHA}
- docker push $IMAGE_NAME:latest
"Deploy to Production":
extends: .deployment
stage: production
variables:
ENVIRONMENT: prod
IMAGE_TAG: ${CI_COMMIT_SHORT_SHA}
only:
- master
.deployment:
image: devth/helm:v2.16.1
script:
- mkdir -p /etc/deploy
- cat $GKE_SERVICE_ACCOUNT | base64 -d > /etc/deploy/sa.json
- gcloud auth activate-service-account --key-file /etc/deploy/sa.json --project $GKE_PROJECT
- gcloud container clusters get-credentials $GKE_CLUSTER_NAME --zone $GKE_ZONE --project $GKE_PROJECT
- helm init --client-only --skip-refresh
- helm upgrade -i $PROJECT_NAME helm/$PROJECT_NAME --namespace osrm --wait --set image.tag=$IMAGE_TAG -f helm/$PROJECT_NAME/values.yaml