Skip to content

Instantly share code, notes, and snippets.

@kevinmcalear
Forked from ljulliar/cloudbuild.yaml
Created March 27, 2020 11:11
Show Gist options
  • Save kevinmcalear/bf0eb0646e76835763877526e826894e to your computer and use it in GitHub Desktop.
Save kevinmcalear/bf0eb0646e76835763877526e826894e to your computer and use it in GitHub Desktop.
Cloud Build YAML file (Photo Album app on Google Cloud Run)
steps:
# Decrypt Rails Master key file
- name: gcr.io/cloud-builders/gcloud
args: ["kms", "decrypt", "--ciphertext-file=./config/master.key.enc",
"--plaintext-file=./config/master.key",
"--location=us-central1","--keyring=photo-album",
"--key=rails_master_key"]
# Decrypt Photo Album service account credentials
- name: gcr.io/cloud-builders/gcloud
args: ["kms", "decrypt", "--ciphertext-file=./config/photo_album_runner.key.enc",
"--plaintext-file=./config/photo_album_runner.key",
"--location=us-central1","--keyring=photo-album",
"--key=photo_album_runner_key"]
# Build image with tag 'latest' and pass decrypted Rails DB password as argument
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag', 'gcr.io/$PROJECT_ID/photo_album:latest',
'--build-arg', 'DB_PWD', '.']
secretEnv: ['DB_PWD']
# Push new image to Google Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/photo_album:latest']
secrets:
- kmsKeyName: projects/project_id/locations/us-central1/keyRings/photo-album/cryptoKeys/db_pwd_key
secretEnv:
DB_PWD: "your_encrypted_production_database_password_here"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment