Skip to content

Commit a0753b5

Browse files
committed
Set up Deployment
1 parent be5f8dd commit a0753b5

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

.github/workflows/backend-cd.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: cd
2+
on:
3+
push:
4+
paths:
5+
- 'backend/**'
6+
branches:
7+
- main
8+
jobs:
9+
deploy:
10+
name: deploy
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
17+
- id: 'auth'
18+
uses: 'google-github-actions/auth@v2'
19+
with:
20+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
21+
22+
- name: 'Set up Cloud SDK'
23+
uses: 'google-github-actions/setup-gcloud@v2'
24+
25+
- name: 'Build and Deploy Image To Artifact Registry'
26+
run: |
27+
cd backend
28+
gcloud builds submit --tag asia-northeast1-docker.pkg.dev/my-backends-459605/eduassistant-backend-repo/eduassistant-backend:latest
29+
30+
- name: Deploy to Cloud Run
31+
run: gcloud run deploy eduassistant-backend --image asia-northeast1-docker.pkg.dev/my-backends-459605/eduassistant-backend-repo/eduassistant-backend:latest --region asia-northeast1 --allow-unauthenticated --project my-backends-459605 --max-instances=4 --set-secrets=GOOGLE_API_KEY=EDUASSISTANT_GEMINI_KEY:latest --set-env-vars=GOOGLE_GENAI_USE_VERTEXAI=FALSE

backend/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ USER myuser
3939

4040
ENV PATH="/opt/venv/bin:$PATH"
4141

42-
EXPOSE 8080
42+
EXPOSE 8000
4343

44-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
44+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

backend/main.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import uvicorn
44
from google.adk.cli.fast_api import get_fast_api_app
55

6-
76
AGENT_DIR = os.path.dirname(os.path.abspath(__file__))
87
ALLOWED_ORIGINS = ["http://localhost", "http://localhost:8080", "*"]
98
SERVE_WEB_INTERFACE = True
@@ -14,6 +13,5 @@
1413
web=SERVE_WEB_INTERFACE,
1514
)
1615

17-
1816
if __name__ == "__main__":
19-
uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))
17+
uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8000)))

0 commit comments

Comments
 (0)