forked from gmflau/google-dev-day-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
82 lines (68 loc) · 2.34 KB
/
cloudbuild.yaml
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
steps:
### Build Images
- id: build-images
name: 'gcr.io/cloud-builders/docker'
env:
- "PROJECT_ID=$PROJECT_ID"
- "_API_GATEWAY_IP=${_API_GATEWAY_IP}"
- "_DATABASE_URI=${_DATABASE_URI}"
- "_REDIS_URI=${_REDIS_URI}"
- "_REDIS_INSIGHT_PORT=${_REDIS_INSIGHT_PORT}"
script: |
#!/bin/bash
set -e
# Install Linux libraries for envsubst
apt-get update -y
apt-get install gettext-base -y
# Inject IPs for ENV
mv .env /tmp/.env
envsubst < /tmp/.env > .env
more .env
docker compose build
### Push Images
- id: push-images
name: 'gcr.io/cloud-builders/docker'
env:
- "PROJECT_ID=$PROJECT_ID"
args: [ 'compose', 'push' ]
### Deploy
- id: 'deploy'
name: 'gcr.io/cloud-builders/gcloud'
env:
- "PROJECT_ID=$PROJECT_ID"
- "_GKE_CLUSTER=${_GKE_CLUSTER}"
- "_GKE_ZONE=${_GKE_ZONE}"
- "_API_GATEWAY_IP=${_API_GATEWAY_IP}"
- "_CLIENT_IP=${_CLIENT_IP}"
- "_DATABASE_URI=${_DATABASE_URI}"
- "_REDIS_URI=${_REDIS_URI}"
- "_REDIS_INSIGHT_PORT=${_REDIS_INSIGHT_PORT}"
- "_IS_RDI_ENABLED=${_IS_RDI_ENABLED}"
script: |
#!/bin/bash
set -e
# Install Linux libraries for envsubst
apt-get update -y
apt-get install gettext-base -y
# Inject IPs for ENV-CONFIG, API and CLIENT services
mv ./k8s/env-configmap.yaml /tmp/env-configmap.yaml
envsubst < /tmp/env-configmap.yaml > ./k8s/env-configmap.yaml
mv ./k8s/api-gateway-service.yaml /tmp/api-gateway-service.yaml
envsubst < /tmp/api-gateway-service.yaml > ./k8s/api-gateway-service.yaml
mv ./k8s/client-service.yaml /tmp/client-service.yaml
envsubst < /tmp/client-service.yaml > ./k8s/client-service.yaml
# Deploy App
gcloud container clusters get-credentials ${_GKE_CLUSTER} \
--project $PROJECT_ID \
--zone ${_GKE_ZONE}
# Deploy env and db-seed
for f in k8s/*.yaml; do envsubst < $f | kubectl apply -n default -f -; done
substitutions:
_GKE_CLUSTER: gke-cluster
_GKE_ZONE: us-central1
_API_GATEWAY_IP: 0.0.0.0
_CLIENT_IP: 0.0.0.0
_DATABASE_URI: postgresql://prisma:prisma@postgresql-server:5432/dbFashion?schema=public
_REDIS_URI: redis://redis-server:6379
_REDIS_INSIGHT_PORT: "6379"
_IS_RDI_ENABLED: "false"