Skip to content

Commit

Permalink
github actions + plugins Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
josancamon19 committed Sep 1, 2024
1 parent d8fe5ff commit 7664515
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
47 changes: 47 additions & 0 deletions .github/workflows/gcp_plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy Backend to Cloud RUN

# TODO: determine if changes to backend folder before pushing

on:
push:
branches: [ "main", "development" ]
paths:
- 'plugins/example/**'

env:
SERVICE: backend
REGION: us-central1

jobs:
deploy:
environment: ${{ (github.ref == 'refs/heads/development' && 'development') || (github.ref == 'refs/heads/main' && 'prod') }}
permissions:
contents: 'read'
id-token: 'write'

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v0'
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 plugins/example/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 }}

# If required, use the Cloud Run url output in later steps
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}
16 changes: 16 additions & 0 deletions plugins/example/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM tiangolo/uvicorn-gunicorn:python3.11

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

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

COPY plugins/example/ /app

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

0 comments on commit 7664515

Please sign in to comment.