forked from amplication/amplication
-
Notifications
You must be signed in to change notification settings - Fork 1
/
production.cloudbuild.yaml
51 lines (46 loc) · 1.8 KB
/
production.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
steps:
- id: "docker-pull"
name: "gcr.io/cloud-builders/docker"
args: ["pull", "$_IMAGE:$SHORT_SHA"]
- id: "docker-pull-app-base"
name: "gcr.io/cloud-builders/docker"
args: ["pull", "$_APP_BASE_IMAGE:$SHORT_SHA"]
waitFor: ["-"]
- id: "docker-inspect"
name: "gcr.io/cloud-builders/docker"
entrypoint: bash
args:
- -c
- |
set -o xtrace;
image_id=$(docker inspect --format='{{index .RepoDigests 0}}' $_IMAGE:$SHORT_SHA);
generated_app_base_image_id=$(docker inspect --format='{{index .RepoDigests 0}}' $_APP_BASE_IMAGE:$SHORT_SHA);
printf "\\nimage_id = \"$image_id\"\\ngenerated_app_base_image_id = \"$generated_app_base_image_id\"" >> terraform/envs/production/terraform.tfvars;
waitFor: ["docker-pull", "docker-pull-app-base"]
- id: "terraform-init"
name: "hashicorp/terraform:0.13.5"
args: ["init"]
dir: terraform/envs/production
waitFor: ["-"]
- id: "terraform-apply"
name: "hashicorp/terraform:0.13.5"
args:
- "apply"
- "-auto-approve"
# 20 minutes
- "-lock-timeout=1200s"
dir: terraform/envs/production
waitFor: ["terraform-init", "docker-inspect"]
- name: "node:12-stretch"
entrypoint: bash
args:
- -c
- |
set -e;
wget -O /workspace/cloud_sql_proxy https://storage.googleapis.com/cloudsql-proxy/v1.16/cloud_sql_proxy.linux.386;
chmod +x /workspace/cloud_sql_proxy;
/workspace/cloud_sql_proxy -dir=/workspace -instances=$PROJECT_ID:$_REGION:$_DB_INSTANCE=tcp:5432 & sleep 2
cd packages/amplication-server/prisma/;
POSTGRESQL_URL="postgresql://$_POSTGRESQL_USER:$_POSTGRESQL_PASSWORD@localhost:5432/$_POSTGRESQL_DB" npx @prisma/[email protected] migrate up --create-db --auto-approve --experimental;
# 1 hour
timeout: 3600s