steps:
  # Build the container image
  - name: 'gcr.io/cloud-builders/docker'
    args: ['build', '-t', 'gcr.io/$PROJECT_ID/strongbody-api:$BUILD_ID', '.']
  
  # Push the container image to Container Registry
  - name: 'gcr.io/cloud-builders/docker'
    args: ['push', 'gcr.io/$PROJECT_ID/strongbody-api:$BUILD_ID']
  
  # Deploy container image to Cloud Run
  - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
    entrypoint: gcloud
    args:
      - 'run'
      - 'deploy'
      - 'strongbody-api'
      - '--image'
      - 'gcr.io/$PROJECT_ID/strongbody-api:$BUILD_ID'
      - '--region'
      - 'asia-southeast1'
      - '--platform'
      - 'managed'
      - '--allow-unauthenticated'
      - '--port'
      - '8080'
      - '--memory'
      - '4Gi'
      - '--cpu'
      - '2'
      - '--min-instances'
      - '0'
      - '--max-instances'
      - '10'
      - '--concurrency'
      - '1000'
      - '--timeout'
      - '300'
      - '--vpc-connector'
      - 'strongbody-vpc-connector'
      - '--vpc-egress'
      - 'all-traffic'
      - '--set-env-vars'
      - 'SERVER_PORT=8080,SERVER_HOST=0.0.0.0,APP_URL=https://strongbody-api-92266159995.asia-southeast1.run.app,WEB_URL=https://strongbody.ai,X_API_KEY=your_api_key,DB_HOST=10.31.0.3,DB_PORT=5432,DB_USER=postgres,DB_PASSWORD=strongbody@123a,DB_NAME=strongbody-prod,DB_SSLMODE=disable,DB_TIMEZONE=Asia/Ho_Chi_Minh,SECRET_KEY=123123123123123123123123112312312,TIME_ACCESS=1000000h,TIME_REFRESH=1000001h,NAME_EMAIL=strongbodyai,ACCOUNT_EMAIL=network@strongbody.ai,PASSWORD_EMAIL=lkly fdqr kihd iazd,GOOGLE_CLOUD_PROJECT=strongbody-462009,BUCKET_NAME=strongbody,CREDENTIALS_PATH=internal/config/credentials/gcp.json,GOOGLE_APPLICATION_CREDENTIALS=internal/config/credentials/voice.json,STRIPE_SECRET_KEY=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,KEY_ID=59PM27DGF6,CLIENT_ID=com.multime.ai,TEAM_ID=GW6B397VD6,APPLE_PATH=internal/config/credentials/Auth_59PM27DGF6.p8,PUBNUB_PUBLISH_KEY=pub-c-6997bc1f-cbad-4bd5-a13c-c7dffc9e1ebe,PUBNUB_SUBSCRIBE_KEY=sub-c-1285cce0-ea32-4bcc-a759-0caf713f0619,PUBNUB_SECRET_KEY=sec-c-ZmM5ZDEyMDItNTRjOS00NGM2LWFlODQtOGI0NzhmOWFiMjdl,PUBNUB_TTL_SECONDS=1440,KAFKA_BOOTSTRAP_SERVERS=disabled,KAFKA_SASL_USERNAME=,KAFKA_SASL_PASSWORD=,RESET_PASSWORD_URL=https://strongbody.ai/set-password,SET_PASSWORD_URL=https://strongbody.ai/set-password'
      - '--execution-environment'
      - 'gen2'

# Store images in Google Container Registry
images:
  - 'gcr.io/$PROJECT_ID/strongbody-api:$BUILD_ID'

# Build options
options:
  logging: CLOUD_LOGGING_ONLY
  machineType: 'E2_HIGHCPU_8'
