-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
62 lines (57 loc) · 1.99 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
stages:
- dockerbuild
- gkedeploy
docker build webapp:
stage: dockerbuild
image: docker:stable
services:
- docker:dind
variables:
CONTAINER_IMAGE: ${CI_REGISTRY}/african-names/back/african-names/africannames-webapp
before_script:
- docker info
- echo "${CI_REGISTRY_PASSWORD}" | docker login registry.gitlab.com --username ${CI_REGISTRY_USER} --password-stdin
script:
- docker build --pull --cache-from "${CONTAINER_IMAGE}:latest" -t "${CONTAINER_IMAGE}:${CI_COMMIT_SHORT_SHA}" .
- docker tag "${CONTAINER_IMAGE}:${CI_COMMIT_SHORT_SHA}" "${CONTAINER_IMAGE}:latest"
- docker push "${CONTAINER_IMAGE}:${CI_COMMIT_SHORT_SHA}"
- docker push "${CONTAINER_IMAGE}:latest"
after_script:
- docker logout ${CI_REGISTRY}
only:
- tags
- master
docker build frontend:
stage: dockerbuild
image: docker:stable
services:
- docker:dind
variables:
CONTAINER_IMAGE: ${CI_REGISTRY}/african-names/back/african-names/africannames-front
before_script:
- docker info
- echo "${CI_REGISTRY_PASSWORD}" | docker login registry.gitlab.com --username ${CI_REGISTRY_USER} --password-stdin
script:
- cd src/main/frontend
- docker build --pull --cache-from "${CONTAINER_IMAGE}:latest" -t "${CONTAINER_IMAGE}:${CI_COMMIT_SHORT_SHA}" .
- docker tag "${CONTAINER_IMAGE}:${CI_COMMIT_SHORT_SHA}" "${CONTAINER_IMAGE}:latest"
- docker push "${CONTAINER_IMAGE}:${CI_COMMIT_SHORT_SHA}"
- docker push "${CONTAINER_IMAGE}:latest"
after_script:
- docker logout ${CI_REGISTRY}
only:
- tags
- master
gcloud deploy:
stage: gkedeploy
image: google/cloud-sdk
script:
- base64 -d $GCP_SERVICE_ACCOUNT_KEY > ~/encoded_serviceaccount.json
- gcloud auth activate-service-account --key-file ~/encoded_serviceaccount.json
- gcloud config set project $GCP_PROJECT_ID
- gcloud config set compute/zone us-central1-a
- gcloud container clusters get-credentials $GKE_CLUSTER_NAME
- kubectl apply -f ./k8/
only:
- tags
- master