-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (110 loc) · 4.6 KB
/
docker.yml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Docker Image CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build the Docker image
run: |
docker build -t chat-with-llms-backend:latest .
- name: Configure GCP Credentials
if: github.ref == 'refs/heads/main'
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.SERVICE_ACCOUNT_JSON }}
project_id: chat-with-llms-dcefd
export_default_credentials: true
- name: Configure Docker Client
if: github.ref == 'refs/heads/main'
run: |-
gcloud auth configure-docker asia-south1-docker.pkg.dev --quiet
- name: Push the Docker image
if: github.ref == 'refs/heads/main'
env:
ARTIFACT_REGISTRY_URL: asia-south1-docker.pkg.dev/chat-with-llms-dcefd/chat-with-llms-backend
run: |
docker tag chat-with-llms-backend:latest $ARTIFACT_REGISTRY_URL/chat-with-llms-backend:latest
docker push $ARTIFACT_REGISTRY_URL/chat-with-llms-backend:latest
build-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build the Docker image
run: |
docker build -t chat-with-llms-frontend:latest ./web \
--build-arg REACT_APP_GOOGLE_CLIENT_ID=${{ secrets.REACT_APP_GOOGLE_CLIENT_ID }} \
--build-arg REACT_APP_API_HOST=${{ secrets.REACT_APP_API_HOST }} \
--build-arg REACT_APP_RAZOR_PAY_KEY_ID=${{ secrets.REACT_APP_RAZOR_PAY_KEY_ID }}
- name: Configure GCP Credentials
if: github.ref == 'refs/heads/main'
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.SERVICE_ACCOUNT_JSON }}
project_id: chat-with-llms-dcefd
export_default_credentials: true
- name: Configure Docker Client
if: github.ref == 'refs/heads/main'
run: |-
gcloud auth configure-docker asia-south1-docker.pkg.dev --quiet
- name: Push the Docker image
if: github.ref == 'refs/heads/main'
env:
ARTIFACT_REGISTRY_URL: asia-south1-docker.pkg.dev/chat-with-llms-dcefd/chat-with-llms-frontend
run: |
docker tag chat-with-llms-frontend:latest $ARTIFACT_REGISTRY_URL/chat-with-llms-frontend:latest
docker push $ARTIFACT_REGISTRY_URL/chat-with-llms-frontend:latest
deploy-backend:
needs: build-backend
runs-on: ubuntu-latest
if: (github.event_name == 'push' || github.event_name == 'pull_request') && github.ref == 'refs/heads/main'
steps:
- name: Configure GCP Credentials
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.SERVICE_ACCOUNT_JSON }}
project_id: chat-with-llms-dcefd
export_default_credentials: true
# deploy to cloud run
- name: Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@main
with:
service_name: "chat-with-llms-backend" # Replace with the name of your existing Cloud Run service
image: "asia-south1-docker.pkg.dev/chat-with-llms-dcefd/chat-with-llms-backend/chat-with-llms-backend:latest"
platform: "managed"
region: "asia-south1"
service: "chat-with-llms-backend"
port: 8080
deploy-frontend:
needs: build-frontend
runs-on: ubuntu-latest
if: (github.event_name == 'push' || github.event_name == 'pull_request') && github.ref == 'refs/heads/main'
steps:
- name: Configure GCP Credentials
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.SERVICE_ACCOUNT_JSON }}
project_id: chat-with-llms-dcefd
export_default_credentials: true
# deploy to cloud run
- name: Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@main
with:
service_name: "chat-with-llms-frontend" # Replace with the name of your existing Cloud Run service
image: "asia-south1-docker.pkg.dev/chat-with-llms-dcefd/chat-with-llms-frontend/chat-with-llms-frontend:latest"
platform: "managed"
region: "asia-south1"
service: "chat-with-llms-frontend"
port: 3000