Skip to content

Commit

Permalink
Fix cloud run job deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki0920 committed Oct 6, 2024
1 parent 6fed947 commit 01a2877
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 119 deletions.
130 changes: 13 additions & 117 deletions ruby/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,124 +2,20 @@ steps:
# build the container image
- id: 'Build container image'
name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/company-ranking-job:$COMMIT_SHA', '-f', 'ruby/Dockerfile.prod', '.']
# push the container image to Artifact Registry
- id: 'Push container image to Artifact Registry'
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/company-ranking-job:$COMMIT_SHA'
- '-t'
- 'gcr.io/$PROJECT_ID/company-ranking-job:latest'
- '-f'
- 'ruby/Dockerfile.prod'
- '.'
- id: 'Push container image with COMMIT_SHA tag'
name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/company-ranking-job:$COMMIT_SHA']
# Deploy container image to Cloud Run
- id: 'Deploy container image to Cloud Run'
name: 'gcr.io/cloud-builders/gcloud'
args:
- 'run'
- 'jobs'
- 'deploy'
- 'company-ranking-job'
- '--image'
- 'gcr.io/$PROJECT_ID/company-ranking-job:$COMMIT_SHA'
- '--region'
- 'asia-northeast1'
- '--max-retries'
- '1'
- '--set-env-vars'
- 'RAILS_ENV=production'
- '--set-env-vars'
- 'RAILS_LOG_TO_STDOUT=enabled'
- '--set-secrets'
- 'DATABASE_URL=DATABASE_URL:latest'
- '--set-secrets'
- 'SECRET_KEY_BASE=SECRET_KEY_BASE:latest'
- id: 'Deploy save-document-summary-daily-job'
name: 'gcr.io/cloud-builders/gcloud'
args:
- 'run'
- 'jobs'
- 'deploy'
- 'save-document-summary-daily-job'
- '--image'
- 'gcr.io/$PROJECT_ID/company-ranking-job:$COMMIT_SHA'
- '--region'
- 'asia-northeast1'
- '--max-retries'
- '1'
- '--set-env-vars'
- 'RAILS_ENV=production'
- '--set-env-vars'
- 'RAILS_LOG_TO_STDOUT=enabled'
- '--set-secrets'
- 'DATABASE_URL=DATABASE_URL:latest'
- '--set-secrets'
- 'SECRET_KEY_BASE=SECRET_KEY_BASE:latest'
- '--args'
- 'bin/rake,save_document_summary:day'
- id: 'Deploy save-document-detail-job'
name: 'gcr.io/cloud-builders/gcloud'
args:
- 'run'
- 'jobs'
- 'deploy'
- 'save-document-detail-job'
- '--image'
- 'gcr.io/$PROJECT_ID/company-ranking-job:$COMMIT_SHA'
- '--region'
- 'asia-northeast1'
- '--max-retries'
- '1'
- '--set-env-vars'
- 'RAILS_ENV=production'
- '--set-env-vars'
- 'RAILS_LOG_TO_STDOUT=enabled'
- '--set-secrets'
- 'DATABASE_URL=DATABASE_URL:latest'
- '--set-secrets'
- 'SECRET_KEY_BASE=SECRET_KEY_BASE:latest'
- '--args'
- 'bin/rake,save_document_detail:batch'
- id: 'Deploy save-securities-job'
name: 'gcr.io/cloud-builders/gcloud'
args:
- 'run'
- 'jobs'
- 'deploy'
- 'save-securities-job'
- '--image'
- 'gcr.io/$PROJECT_ID/company-ranking-job:$COMMIT_SHA'
- '--region'
- 'asia-northeast1'
- '--max-retries'
- '1'
- '--set-env-vars'
- 'RAILS_ENV=production'
- '--set-env-vars'
- 'RAILS_LOG_TO_STDOUT=enabled'
- '--set-secrets'
- 'DATABASE_URL=DATABASE_URL:latest'
- '--set-secrets'
- 'SECRET_KEY_BASE=SECRET_KEY_BASE:latest'
- '--args'
- 'bin/rake,save_securities:all'
- id: 'Deploy destroy-old-documents'
name: 'gcr.io/cloud-builders/gcloud'
args:
- 'run'
- 'jobs'
- 'deploy'
- 'destroy-old-documents'
- '--image'
- 'gcr.io/$PROJECT_ID/company-ranking-job:$COMMIT_SHA'
- '--region'
- 'asia-northeast1'
- '--max-retries'
- '1'
- '--set-env-vars'
- 'RAILS_ENV=production'
- '--set-env-vars'
- 'RAILS_LOG_TO_STDOUT=enabled'
- '--set-secrets'
- 'DATABASE_URL=DATABASE_URL:latest'
- '--set-secrets'
- 'SECRET_KEY_BASE=SECRET_KEY_BASE:latest'
- '--args'
- 'bin/rake,destroy_old_documents:execute'
- id: 'Push container image with latest tag'
name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/company-ranking-job:latest']
images:
- 'gcr.io/$PROJECT_ID/company-ranking-job:$COMMIT_SHA'
3 changes: 1 addition & 2 deletions terraform/prod/google_cloud_run_v2_job.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ resource "google_cloud_run_v2_job" "job" {
containers {
args = each.value.args
command = []
image = ""
image = "gcr.io/company-ranking-prod/company-ranking-job:latest"
env {
name = "RAILS_ENV"
value = "production"
Expand Down Expand Up @@ -83,7 +83,6 @@ resource "google_cloud_run_v2_job" "job" {
ignore_changes = [
client,
client_version,
template.0.template.0.containers.0.image
]
}
}

0 comments on commit 01a2877

Please sign in to comment.