54 lines
2.0 KiB
YAML

steps:
# Build the container image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA', '.']
# Push the container image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA']
# Tag the image as latest
- name: 'gcr.io/cloud-builders/docker'
args: ['tag', 'gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA', 'gcr.io/$PROJECT_ID/sereact-api:latest']
# Push the latest tag
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/sereact-api:latest']
# Deploy to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'sereact'
- '--image=gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA'
- '--region=us-central1'
- '--platform=managed'
- '--allow-unauthenticated'
- '--set-env-vars=GCS_BUCKET_NAME=${_GCS_BUCKET_NAME},DATABASE_NAME=${_DATABASE_NAME},VECTOR_DB_ENVIRONMENT=${_VECTOR_DB_ENVIRONMENT},VECTOR_DB_INDEX_NAME=${_VECTOR_DB_INDEX_NAME},LOG_LEVEL=INFO'
- '--set-secrets=DATABASE_URI=sereact-db-uri:latest,API_KEY_SECRET=sereact-api-key-secret:latest,VECTOR_DB_API_KEY=sereact-vector-db-key:latest'
# Optional: Run tests after deployment
# - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
# entrypoint: /bin/bash
# args:
# - '-c'
# - |
# SERVICE_URL=$(gcloud run services describe sereact --region=us-central1 --format='value(status.url)')
# curl -s -o /dev/null -w "%{http_code}" $${SERVICE_URL}/health | grep 200
# Store images in Container Registry
images:
- 'gcr.io/$PROJECT_ID/sereact-api:$COMMIT_SHA'
- 'gcr.io/$PROJECT_ID/sereact-api:latest'
# Substitution variables to be set in the Cloud Build trigger
substitutions:
_GCS_BUCKET_NAME: 'your-app-storage-bucket'
_DATABASE_NAME: 'imagedb'
_VECTOR_DB_ENVIRONMENT: 'your-pinecone-env'
_VECTOR_DB_INDEX_NAME: 'image-embeddings'
# Increase timeout to 30 minutes
timeout: '1800s'