Skip to content

Commit

Permalink
Write CI/CD pipeline for speech models service
Browse files Browse the repository at this point in the history
  • Loading branch information
thainguyensunya committed Dec 19, 2024
1 parent 95bf0e5 commit a8b6298
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions .github/workflows/gcp_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
env:
SERVICE: models
REGION: us-central1
CONTAINER_NAME: speech-models

jobs:
deploy:
Expand Down Expand Up @@ -40,9 +41,36 @@ jobs:

- 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 }}
docker build -t gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}:${GITHUB_SHA::7} -f backend/modal/Dockerfile .
docker push gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}:${GITHUB_SHA::7}
- name: Create SSH Key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SPEECH_MODELS_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
- name: Deploy Docker image
run: |
ssh -o StrictHostKeyChecking=no \
${{ secrets.SPEECH_MODELS_SSH_USERNAME }}@${{ secrets.SPEECH_MODELS_SSH_HOST }} \
"set -x; \
echo '[+] Pull latest Speech Models image...'; \
docker pull gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}:${GITHUB_SHA::7}; \
echo '[+] Remove current Speech Models container...'; \
docker rm -f ${{ env.CONTAINER_NAME }}; \
echo '[+
] Start new Speech Models container...'; \
docker run -d --name ${{ env.CONTAINER_NAME }} -p 8080:8080 \
--volume /var/lib/nvidia/lib64:/usr/local/nvidia/lib64 \
--volume /var/lib/nvidia/bin:/usr/local/nvidia/bin \
--device /dev/nvidia0:/dev/nvidia0 \
--device /dev/nvidia-uvm:/dev/nvidia-uvm \
--device /dev/nvidiactl:/dev/nvidiactl \
-e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} \
-e HUGGINGFACE_TOKEN=${{ secrets.HUGGINGFACE_TOKEN }} \
gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}:${GITHUB_SHA::7}"
# - name: Deploy to Cloud Run
# id: deploy
# uses: google-github-actions/deploy-cloudrun@v2
Expand All @@ -52,5 +80,5 @@ jobs:
# image: gcr.io/${{ vars.GCP_PROJECT_ID }}/${{ env.SERVICE }}

# If required, use the Cloud Run url output in later steps
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}
# - name: Show Output
# run: echo ${{ steps.deploy.outputs.url }}

0 comments on commit a8b6298

Please sign in to comment.