Create and publish backend image #69
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
name: Create and publish backend image | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
tags: | |
description: 'Docker image tag (e.g: v0.0.1)' | |
required: false | |
type: string | |
env: | |
IMAGE_NAME: cohere-toolkit-backend | |
jobs: | |
build-and-push-backend-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Login | |
uses: google-github-actions/setup-gcloud@v0 | |
with: | |
project_id: ${{ vars.GCP_PROJECT_ID }} | |
service_account_email: ${{ secrets.SA_EMAIL }} | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
- name: Configure Docker | |
run: gcloud auth configure-docker --quiet | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- run: 'echo "$KEY" > ./key.json' | |
shell: bash | |
env: | |
KEY: ${{ secrets.GCP_SA_KEY }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ vars.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build Docker image | |
run: | | |
docker build -t ${{ env.IMAGE_NAME }} -f ./src/backend/Dockerfile . | |
- name: Tag Docker image | |
run: | | |
docker tag ${{ env.IMAGE_NAME }} ${{ steps.meta.outputs.tags }} | |
- name: Push Docker image | |
run: | | |
docker push ${{ steps.meta.outputs.tags }} | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy ${{ env.IMAGE_NAME }} \ | |
--project=${{ vars.GCP_PROJECT_ID }} \ | |
--image=${{ steps.meta.outputs.tags }} \ | |
--platform=managed \ | |
--region=us-central1 \ | |
--allow-unauthenticated \ | |
--update-env-vars=DATABASE_URL=${{ secrets.DATABASE_URL }},COHERE_API_KEY=${{ secrets.COHERE_API_KEY }},MINIMAP_API_URL=${{ vars.MINIMAP_API_URL }} \ | |
--memory=4Gi \ | |
--cpu=4 \ | |
--max-instances=1 |