-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from tommylees112/dev
Dev
- Loading branch information
Showing
8 changed files
with
160 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
FLASK_APP=INSERT_HERE | ||
COHERE_API_KEY=INSERT_HERE | ||
TWILIO_ACCOUNT_SID=INSERT_HERE | ||
TWILIO_AUTH_TOKEN=INSERT_HERE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# .github/workflows/deploy.yml | ||
|
||
name: Deploy FastAPI to Google Cloud Run | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Triggers the workflow on pushes to the 'main' branch | ||
- dev | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
env: | ||
GCP_PROJECT_ID: whatsappllm | ||
GCP_REGION: europe-west3 | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Checkout the repository | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
# Step 2: Authenticate to Google Cloud | ||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
|
||
# Step 2.1: Verify Authentication [DEBUG] | ||
- name: Verify Authentication | ||
run: | | ||
gcloud auth list | ||
gcloud config list project | ||
# Step 3: Configure Docker to use Google Cloud credentials | ||
- name: Configure Docker for GCR | ||
run: | | ||
gcloud auth configure-docker gcr.io | ||
# Step 3.1: Test Docker Authentication | ||
- name: Test Docker Authentication | ||
run: | | ||
docker info | ||
# Step 4: Build the Docker image | ||
- name: Build Docker Image | ||
run: | | ||
IMAGE=gcr.io/$GCP_PROJECT_ID/whatsappllm:${{ github.sha }} | ||
docker build -t $IMAGE . | ||
# Step 5: Push the Docker image to GCR | ||
- name: Push Docker Image to GCR | ||
run: | | ||
IMAGE=gcr.io/$GCP_PROJECT_ID/whatsappllm:${{ github.sha }} | ||
docker push $IMAGE | ||
# Ensure the image name matches the build step | ||
|
||
# Step 6: Deploy to Google Cloud Run | ||
- name: Deploy to Cloud Run | ||
run: | | ||
gcloud run deploy whatsappllm-service \ | ||
--image gcr.io/$GCP_PROJECT_ID/whatsappllm:${{ github.sha }} \ | ||
--region $GCP_REGION \ | ||
--platform managed \ | ||
--allow-unauthenticated \ | ||
--update-secrets=TWILIO_ACCOUNT_SID=TWILIO_ACCOUNT_SID:latest \ | ||
--update-secrets=TWILIO_AUTH_TOKEN=TWILIO_AUTH_TOKEN:latest \ | ||
--update-secrets=TWILIO_PHONE_NUMBER=TWILIO_PHONE_NUMBER:latest \ | ||
--update-secrets=COHERE_API_KEY=COHERE_API_KEY:latest | ||
# Optional Step 7: Clean Up Docker Images (To save storage on the runner) | ||
- name: Clean Up Docker Images | ||
if: always() | ||
run: | | ||
docker image prune -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
FROM python:3.9-slim@sha256:980b778550c0d938574f1b556362b27601ea5c620130a572feb63ac1df03eda5 | ||
FROM python:3.11 | ||
|
||
ENV PYTHONUNBUFFERED True | ||
|
||
ENV APP_HOME /app | ||
WORKDIR $APP_HOME | ||
COPY . ./ | ||
|
||
# set the port to 1234 | ||
ENV PORT 1234 | ||
|
||
# create the environment and install the dependencies | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# As an example here we're running the web service with one worker on uvicorn. | ||
CMD exec uvicorn src.main:app --host 0.0.0.0 --port ${PORT} --workers 1 | ||
# CMD exec uvicorn src.main:app --host 0.0.0.0 --workers 1 | ||
CMD fastapi dev --port=$PORT --host=0.0.0.0 src/main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ python-dotenv | |
python-multipart | ||
twilio | ||
uvicorn | ||
nltk | ||
nltk | ||
fastapi[standard] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters