forked from event-storming/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
89 lines (85 loc) · 2.44 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
82
83
84
85
86
87
88
89
steps:
### Build
- id: 'install'
name: 'gcr.io/cloud-builders/npm'
args: ['install']
- id: 'source build'
name: 'gcr.io/cloud-builders/npm'
args: ['run','build']
- id: 'docker build'
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- '-c'
- |
echo '$COMMIT_SHA =' $COMMIT_SHA
docker build -t gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA .
### Test
### Publish
- id: 'publish'
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- '-c'
- |
docker push gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA
### deploy
- id: 'deploy'
name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
PROJECT=$$(gcloud config get-value core/project)
gcloud container clusters get-credentials "$${CLOUDSDK_CONTAINER_CLUSTER}" \
--project "$${PROJECT}" \
--zone "$${CLOUDSDK_COMPUTE_ZONE}"
_GATEWAY_IP=$$(kubectl get -o jsonpath="{.status.loadBalancer.ingress[0].ip}" svc gateway)
_GATEWAY_PORT=$$(kubectl get -o jsonpath="{.spec.ports[0].port}" svc gateway)
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: $_PROJECT_NAME
labels:
app: $_PROJECT_NAME
spec:
ports:
- port: 8080
targetPort: 8080
selector:
app: $_PROJECT_NAME
type:
LoadBalancer
EOF
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: $_PROJECT_NAME
labels:
app: $_PROJECT_NAME
spec:
replicas: 1
selector:
matchLabels:
app: $_PROJECT_NAME
template:
metadata:
labels:
app: $_PROJECT_NAME
spec:
containers:
- name: $_PROJECT_NAME
image: gcr.io/$PROJECT_ID/$_PROJECT_NAME:$COMMIT_SHA
ports:
- containerPort: 8080
env:
- name: VUE_APP_API_HOST
value: http://$${_GATEWAY_IP}:$${_GATEWAY_PORT}
EOF
options:
env:
# # location/name of GKE cluster (used by all kubectl commands)
- CLOUDSDK_COMPUTE_ZONE=asia-northeast1-a
- CLOUDSDK_CONTAINER_CLUSTER=standard-cluster-1