-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
36 lines (31 loc) · 1.02 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
image: docker:stable
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
GCP_ECR_IMAGE: $GCP_ECR/$GCP_PROJECT/$DOCKER_IMAGE
KUBERNETES_DIR: "./gke"
stages:
- build
- deploy
gcp-build:
stage: build
image: music1353/gcloud:dind
tags:
- docker
script:
- echo $GCP_KEY >> key.json
- gcloud auth activate-service-account --key-file key.json
- gcloud auth configure-docker
- docker build --cache-from $GCP_ECR_IMAGE:latest -t $GCP_ECR_IMAGE .
- docker push $GCP_ECR_IMAGE
gcp-deploy:
stage: deploy
image: music1353/gcloud:dind
script:
- echo $GCP_KEY >> key.json
- gcloud auth activate-service-account --key-file key.json
- gcloud container clusters get-credentials $GCP_CLUSTER_PROJECT --region $GCP_REGION --project $GCP_PROJECT
- kubectl apply -f "$KUBERNETES_DIR/$GCP_APP_NAME.yaml"
- kubectl patch deployment $GCP_APP_NAME -p '{"spec":{"template":{"spec":{"terminationGracePeriodSeconds":32}}}}' # for rollout
- kubectl rollout status deployment $GCP_APP_NAME