-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
145 lines (138 loc) · 6.14 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
options:
logging: CLOUD_LOGGING_ONLY
serviceAccount: "[email protected]"
steps:
# Import DAGs to Cloud Composer
- name: gcr.io/cloud-builders/gsutil
args:
- "-m"
- "rsync"
- "-d"
- "-r"
- "dags"
- "${_GCS_BUCKET}"
# Docker Build Schema
- name: "gcr.io/cloud-builders/docker"
entrypoint: "bash"
args:
[
"-c",
"docker build -f ./schema/Dockerfile -t us-west4-docker.pkg.dev/${PROJECT_ID}/eed-docker-artifact-repository/deploy-db-migrations --build-arg=PGUSER_ARG=$$PGUSER --build-arg=PGPASSWORD_ARG=$$PGPASSWORD --build-arg=PGHOST_ARG=$$PGHOST .",
]
secretEnv: ["PGUSER", "PGPASSWORD", "PGHOST"]
# Docker Push
- name: "gcr.io/cloud-builders/docker"
args:
[
"push",
"us-west4-docker.pkg.dev/${PROJECT_ID}/eed-docker-artifact-repository/deploy-db-migrations",
]
# Entrypoint, timeout and environment variables=
- name: "gcr.io/cloud-builders/gcloud"
args:
[
"beta",
"run",
"jobs",
"create",
"--service-account",
"deploy-db-migrations-${COMMIT_SHA}",
"--image",
"us-west4-docker.pkg.dev/${PROJECT_ID}/eed-docker-artifact-repository/deploy-db-migrations",
"--set-secrets",
"PGUSER=eed_db_user:latest,PGPASSWORD=eed_db_pass:latest,PGHOST=eed_db_host:latest",
"--region",
"us-west4",
"--execute-now",
]
# Docker Build app
- name: "gcr.io/cloud-builders/docker"
entrypoint: "bash"
args:
[
"-c",
"docker build -f ./app/Dockerfile -t us-west4-docker.pkg.dev/${PROJECT_ID}/eed-docker-artifact-repository/app --build-arg NA_SECRET=$$NEXTAUTH_SECRET --build-arg GOOGLE_CLIENT_ID_ARG=$$GOOGLE_CLIENT_ID --build-arg GOOGLE_CLIENT_SECRET_ARG=$$GOOGLE_CLIENT_SECRET --build-arg GITHUB_ID_ARG=$$GITHUB_ID --build-arg GITHUB_SECRET_ARG=$$GITHUB_SECRET --build-arg NEXTAUTH_URL_ARG=$$NEXTAUTH_URL --build-arg DATABASE_PROTOCOL_ARG=$$DATABASE_PROTOCOL --build-arg DATABASE_USER_ADMIN_ARG=$$DATABASE_USER_ADMIN --build-arg DATABASE_USER_PW_ADMIN_ARG=$$DATABASE_USER_PW_ADMIN --build-arg DATABASE_USER_ANALYST_ARG=$$DATABASE_USER_ANALYST --build-arg DATABASE_USER_PW_ANALYST_ARG=$$DATABASE_USER_PW_ANALYST --build-arg DATABASE_HOST_ARG=$$DATABASE_HOST --build-arg DATABASE_PORT_ARG=$$DATABASE_PORT --build-arg DATABASE_ARG=$$DATABASE --build-arg DATABASE_SCHEMA_ADMIN_ARG=$$DATABASE_SCHEMA_ADMIN --build-arg DATABASE_SCHEMA_CLEAN_ARG=$$DATABASE_SCHEMA_CLEAN --build-arg DATABASE_SCHEMA_WORKSPACE_ARG=$$DATABASE_SCHEMA_WORKSPACE --build-arg API_HOST_ARG=$$API_HOST .",
]
secretEnv:
[
"PGUSER",
"PGPASSWORD",
"PGHOST",
"NEXTAUTH_SECRET",
"GOOGLE_CLIENT_ID",
"GOOGLE_CLIENT_SECRET",
"GITHUB_ID",
"GITHUB_SECRET",
"NEXTAUTH_URL",
"DATABASE_PROTOCOL",
"DATABASE_USER_ADMIN",
"DATABASE_USER_PW_ADMIN",
"DATABASE_USER_ANALYST",
"DATABASE_USER_PW_ANALYST",
"DATABASE_HOST",
"DATABASE_PORT",
"DATABASE",
"DATABASE_SCHEMA_ADMIN",
"DATABASE_SCHEMA_CLEAN",
"DATABASE_SCHEMA_WORKSPACE",
"API_HOST",
]
# Docker Push
- name: "gcr.io/cloud-builders/docker"
args:
[
"push",
"us-west4-docker.pkg.dev/${PROJECT_ID}/eed-docker-artifact-repository/app",
]
- name: "gcr.io/cloud-builders/gke-deploy"
args:
- run
- --filename=kubernetes
- --image=us-west4-docker.pkg.dev/${PROJECT_ID}/eed-docker-artifact-repository/app
- --location=us-west4-a
- --cluster=eed-gke
availableSecrets:
secretManager:
- versionName: projects/${PROJECT_ID}/secrets/eed_db_user/versions/latest
env: "PGUSER"
- versionName: projects/${PROJECT_ID}/secrets/eed_db_pass/versions/latest
env: "PGPASSWORD"
- versionName: projects/${PROJECT_ID}/secrets/eed_db_host/versions/latest
env: "PGHOST"
- versionName: projects/${PROJECT_ID}/secrets/eed_nextauth_secret/versions/latest
env: "NEXTAUTH_SECRET"
- versionName: projects/${PROJECT_ID}/secrets/eed_nextauth_google_client_id/versions/latest
env: "GOOGLE_CLIENT_ID"
- versionName: projects/${PROJECT_ID}/secrets/eed_nextauth_google_client_secret/versions/latest
env: "GOOGLE_CLIENT_SECRET"
- versionName: projects/${PROJECT_ID}/secrets/eed_nextauth_github_client_id/versions/latest
env: "GITHUB_ID"
- versionName: projects/${PROJECT_ID}/secrets/eed_nextauth_github_client_secret/versions/latest
env: "GITHUB_SECRET"
- versionName: projects/${PROJECT_ID}/secrets/eed_nextauth_url/versions/latest
env: "NEXTAUTH_URL"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_protocol/versions/latest
env: "DATABASE_PROTOCOL"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_user_admin/versions/latest
env: "DATABASE_USER_ADMIN"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_user_pw_admin/versions/latest
env: "DATABASE_USER_PW_ADMIN"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_user_analyst/versions/latest
env: "DATABASE_USER_ANALYST"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_user_pw_analyst/versions/latest
env: "DATABASE_USER_PW_ANALYST"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_host/versions/latest
env: "DATABASE_HOST"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_port/versions/latest
env: "DATABASE_PORT"
- versionName: projects/${PROJECT_ID}/secrets/eed_database/versions/latest
env: "DATABASE"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_schema_admin/versions/latest
env: "DATABASE_SCHEMA_ADMIN"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_schema_clean/versions/latest
env: "DATABASE_SCHEMA_CLEAN"
- versionName: projects/${PROJECT_ID}/secrets/eed_database_schema_workspace/versions/latest
env: "DATABASE_SCHEMA_WORKSPACE"
- versionName: projects/${PROJECT_ID}/secrets/eed_api_host/versions/latest
env: "API_HOST"