File size: 1,784 Bytes
5fd7795 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | # ==============================================================================
# Google Cloud Build Pipeline for CropAI Backend
# Automatically builds, tests, and deploys to Google Cloud Run
# ==============================================================================
steps:
# 1. Run Unit & Integration Tests
- name: 'python:3.11-slim'
entrypoint: 'bash'
args:
- '-c'
- |
pip install --no-cache-dir -r backend/requirements.txt
python -m unittest backend/tests/test_api.py -v
# 2. Build Container Image with BuildKit
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/cropai-backend:$COMMIT_SHA'
- '-t'
- 'gcr.io/$PROJECT_ID/cropai-backend:latest'
- '-f'
- 'backend/Dockerfile'
- 'backend'
# 3. Push Container Image to Google Container Registry / Artifact Registry
- name: 'gcr.io/cloud-builders/docker'
args:
- 'push'
- 'gcr.io/$PROJECT_ID/cropai-backend:$COMMIT_SHA'
# 4. Deploy to Google Cloud Run (Fully Managed Serverless)
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'cropai-backend'
- '--image'
- 'gcr.io/$PROJECT_ID/cropai-backend:$COMMIT_SHA'
- '--region'
- 'us-central1'
- '--platform'
- 'managed'
- '--allow-unauthenticated'
- '--memory'
- '2Gi'
- '--cpu'
- '2'
- '--min-instances'
- '1'
- '--max-instances'
- '20'
- '--concurrency'
- '80'
- '--timeout'
- '60s'
- '--port'
- '8080'
images:
- 'gcr.io/$PROJECT_ID/cropai-backend:$COMMIT_SHA'
- 'gcr.io/$PROJECT_ID/cropai-backend:latest'
timeout: '900s'
|