# Cloud Build configuration for Autodoc Cloud API
# For local builds from infrastructure/api directory

steps:
  # Build the container image
  - name: 'gcr.io/cloud-builders/docker'
    args:
      - 'build'
      - '-t'
      - 'gcr.io/$PROJECT_ID/autodoc-api:latest'
      - '.'

  # Push the container image
  - name: 'gcr.io/cloud-builders/docker'
    args:
      - 'push'
      - 'gcr.io/$PROJECT_ID/autodoc-api:latest'

  # Deploy to Cloud Run
  - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
    entrypoint: gcloud
    args:
      - 'run'
      - 'deploy'
      - 'autodoc-api'
      - '--image'
      - 'gcr.io/$PROJECT_ID/autodoc-api:latest'
      - '--region'
      - 'us-central1'
      - '--platform'
      - 'managed'
      - '--allow-unauthenticated'
      - '--set-env-vars'
      - 'SUPABASE_URL=https://iowgufboylypltycvwcp.supabase.co'
      - '--memory'
      - '512Mi'
      - '--cpu'
      - '1'
      - '--min-instances'
      - '0'
      - '--max-instances'
      - '10'

images:
  - 'gcr.io/$PROJECT_ID/autodoc-api:latest'

options:
  logging: CLOUD_LOGGING_ONLY
