-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
64 lines (58 loc) · 1.97 KB
/
cloudbuild.yaml
File metadata and controls
64 lines (58 loc) · 1.97 KB
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
# Cloud Build configuration for IQB prototype deployment
# Used for manual deployment: gcloud builds submit --config=cloudbuild.yaml
#
# Based on M-Lab token-exchange pattern, adapted for mlab-sandbox environment
substitutions:
# Default values, can be overridden when submitting the build
_REGION: us-east1
_REPOSITORY: m-lab
_SERVICE_NAME: iqb-prototype
_MEMORY: 1Gi
_CPU: "2"
steps:
# 1. Build the Docker image from prototype/Dockerfile
- name: "gcr.io/cloud-builders/docker"
id: Build
args:
- "build"
- "-f"
- "prototype/Dockerfile"
- "-t"
- "${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/${_SERVICE_NAME}:$BUILD_ID"
- "-t"
- "${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/${_SERVICE_NAME}:latest"
- "."
# 2. Push the container image to Artifact Registry
# Note: This explicit push ensures the image exists before Deploy step runs.
# The BUILD_ID tag gets pushed again via images: section (harmless, just updates metadata).
- name: "gcr.io/cloud-builders/docker"
id: Push
args:
- "push"
- "${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/${_SERVICE_NAME}:$BUILD_ID"
waitFor: ["Build"]
# 3. Deploy to Cloud Run
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
id: Deploy
entrypoint: gcloud
args:
- "run"
- "deploy"
- "${_SERVICE_NAME}"
- "--image"
- "${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/${_SERVICE_NAME}:$BUILD_ID"
- "--platform"
- "managed"
- "--region"
- "${_REGION}"
- "--allow-unauthenticated"
- "--memory=${_MEMORY}"
- "--cpu=${_CPU}"
- "--project=${PROJECT_ID}"
waitFor: ["Push"]
# Push both tagged and latest images to registry
images:
- "${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/${_SERVICE_NAME}:$BUILD_ID"
- "${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/${_SERVICE_NAME}:latest"
# Build timeout (20 minutes)
timeout: 1200s