-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
52 lines (47 loc) Β· 1.5 KB
/
cloudbuild.yaml
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
steps:
# Step 1: Install dependencies and detect changes
- name: 'node:22'
entrypoint: 'bash'
args:
- '-c'
- |
echo "Installing dependencies and NX globally"
npm install -g @nrwl/cli
yarn
# Build all services in the NX monorepo
- name: 'node:22'
entrypoint: 'bash'
args:
- '-c'
- |
yarn nx reset && yarn nx run-many --target=build --all=true
# Conditionally build and push Docker images for apps
- name: 'gcr.io/cloud-builders/docker'
id: 'Build and Push Spacebots API'
entrypoint: 'bash'
args:
- '-c'
- |
docker build -t us-central1-docker.pkg.dev/$PROJECT_ID/tgbot/spacebots-api:$COMMIT_SHA -f ./Dockerfile .
docker push us-central1-docker.pkg.dev/$PROJECT_ID/tgbot/spacebots-api:$COMMIT_SHA
- name: 'gcr.io/cloud-builders/docker'
args:
- 'run'
- '--rm'
- '-e'
- 'DATABASE_URL=${_DATABASE_URL}'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/tgbot/spacebots-api:${COMMIT_SHA}'
- 'npx'
- 'prisma'
- 'migrate'
- 'deploy'
# Deployment steps for bots if their images were built
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
# Deploy Downloader Bot
gcloud run deploy spacebots-api --image=us-central1-docker.pkg.dev/$PROJECT_ID/tgbot/spacebots-api:$COMMIT_SHA --region=europe-west4 --platform=managed --memory=4Gi --cpu=4 --allow-unauthenticated
options:
logging: CLOUD_LOGGING_ONLY