Skip to content

Commit

Permalink
feat: implemented image uploader service
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayanta008 committed May 3, 2024
1 parent 4cb1ced commit 2583dbe
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 2 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/dev_cloudrun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Deploy app
on:
push:
branches:
- main

permissions:
contents: 'read'
id-token: 'write'
checks: 'write'
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}

jobs:
# <------------------- BUILD IMAGE -------------------->
build-image:
name: Build Image
needs: unit-test
runs-on: self-hosted
outputs:
image-name: ${{ steps.build-image.outputs.imageFullName }}
image-tag: ${{ steps.build-image.outputs.tags }}
branch: ${{ env.GITHUB_REF_SLUG_URL }}
steps:
# PREP STEPS
- name: Checkout the code
uses: actions/checkout@v2

- name: Slugify github variables
uses: rlespinasse/github-slug-action@v4

- name: Authenticate to GCP (SA Key)
id: auth
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.APPLICATION_SA }}
export_default_credentials: true

# BUILD AND PUSH THE IMAGE
- name: Build & Push Image
id: build-image
uses: mr-smithers-excellent/docker-build-push@v6
with:
image: ${{ env.PROJECT_ID }}/${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}
registry: "eu.gcr.io"
username: _json_key
password: ${{ secrets.APPLICATION_SA }}

# <------------------ DEPLOY APP to GCP -------------------->
deploy-app:
name: Deploy app
needs: [ build-image, unit-test ]
runs-on: self-hosted
outputs:
env_url: ${{ steps.deploy.outputs.url }}
environment:
name: ${{ needs.build-image.outputs.branch }}
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Slugify github variables
uses: rlespinasse/github-slug-action@v4

- name: Authenticate to GCP (SA Key)
id: auth
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.APPLICATION_SA }}

- name: Deploy to Cloud Run
id: deploy
run: |-
gcloud auth login --brief --cred-file="${{ steps.auth.outputs.credentials_file_path }}" --quiet
gcloud run deploy ${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }} \
--port 8080 \
--project ${{ env.PROJECT_ID }}\
--region "europe-west1" \
--image "${{ needs.build-image.outputs.image-name }}:${{ needs.build-image.outputs.image-tag }}" \
--memory "2048Mi" \
--cpu "1" \
--timeout "5m" \
--concurrency "45" \
--min-instances "0" \
--max-instances "1" \
--service-account ${{ secrets.GCP_SA_ACCNT_NAME }} \
--platform managed \
--no-allow-unauthenticated
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ venv/
ENV/
env.bak/
venv.bak/
*venv

# Spyder project settings
.spyderproject
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ FROM nginx:alpine AS frontend
# Copy the HTML file into the nginx directory
COPY ui/index.html /usr/share/nginx/html/index.html

# Expose port 80
EXPOSE 80

# Copy backend files to the nginx directory
COPY --from=backend /app /app
Expand Down
1 change: 1 addition & 0 deletions api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-cors
werkzeug
numpy
opencv-python

0 comments on commit 2583dbe

Please sign in to comment.