feat: add cloudbuild.yaml generation for new apps

This commit is contained in:
Vikram Rangnekar
2020-05-17 19:16:40 -04:00
parent f6ce0c102b
commit 1c823e4353
34 changed files with 231 additions and 536 deletions

View File

@ -50,6 +50,14 @@ func cmdNew(cmd *cobra.Command, args []string) {
}
})
ifNotExists(path.Join(appPath, "cloudbuild.yaml"), func(p string) error {
if v, err := tmpl.get("cloudbuild.yaml"); err == nil {
return ioutil.WriteFile(p, v, 0644)
} else {
return err
}
})
// Create app config folder and add relevant files
appConfigPath := path.Join(appPath, "config")

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
steps:
# Build image with tag 'latest'
- name: "gcr.io/cloud-builders/docker"
args:
[
"build",
"--tag",
"gcr.io/$PROJECT_ID/{% app_name_slug %}:latest",
"--build-arg",
"GO_ENV=production",
".",
]
# Push new image to Google Container Registry
- name: "gcr.io/cloud-builders/docker"
args: ["push", "gcr.io/$PROJECT_ID/{% app_name_slug %}:latest"]
# Deploy image to Cloud Run
- name: "gcr.io/cloud-builders/gcloud"
args:
[
"run",
"deploy",
"data",
"--image",
"gcr.io/$PROJECT_ID/{% app_name_slug %}:latest",
"--add-cloudsql-instances",
"$PROJECT_ID:$REGION:{% app_name_slug %}_production",
"--region",
"$REGION",
"--platform",
"managed",
"--update-env-vars",
"GO_ENV=production,SG_DATABASE_HOST=/cloudsql/$PROJECT_ID:$REGION:{% app_name_slug %}_production,SECRETS_FILE=prod.secrets.yml",
"--port",
"8080",
"--service-account",
"$SERVICE_ACCOUNT",
"--allow-unauthenticated",
"--verbosity",
"debug",
]