Skip to content

Commit

Permalink
Migrate speech models to GCP Compute engine
Browse files Browse the repository at this point in the history
  • Loading branch information
thainguyensunya committed Nov 30, 2024
1 parent 58e8680 commit ff1e123
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/gcp_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ name: Deploy Speech Models to Cloud RUN

on:
push:
branches: [ "main", "development" ]
# branches: [ "main", "development" ]
branches: "migrate-speed-models-to-gcp"
paths:
- 'backend/modal/**'

Expand All @@ -22,25 +23,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v0'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}

- run: gcloud auth configure-docker

- name: Build and Push Docker image
run: |
docker build -t gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }} -f backend/modal/Dockerfile .
docker push gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v0
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
image: gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}
# - name: Deploy to Cloud Run
# id: deploy
# uses: google-github-actions/deploy-cloudrun@v2
# with:
# service: ${{ env.SERVICE }}
# region: ${{ env.REGION }}
# image: gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}

# If required, use the Cloud Run url output in later steps
- name: Show Output
Expand Down
22 changes: 13 additions & 9 deletions backend/modal/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
FROM tiangolo/uvicorn-gunicorn:python3.11
FROM python:3.11 AS builder

RUN apt-get update && apt-get install --no-install-recommends --no-install-suggests -y curl
RUN apt-get install unzip
RUN apt-get -y install python3
RUN apt-get -y install python3-pip
RUN apt-get -y install git
RUN apt-get -y install ffmpeg
ENV PATH="/opt/venv/bin:$PATH"
RUN python -m venv /opt/venv

COPY backend/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt

COPY backend/modal/ /app
FROM python:3.11-slim

WORKDIR /app
ENV PATH="/opt/venv/bin:$PATH"

RUN apt-get update && apt-get -y install ffmpeg curl unzip && rm -rf /var/lib/apt/lists/*

COPY --from=builder /opt/venv /opt/venv
COPY backend/modal/ .

EXPOSE 8080
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]

0 comments on commit ff1e123

Please sign in to comment.