Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 2.72 KB

cloudbuild_and_run.md

File metadata and controls

63 lines (41 loc) · 2.72 KB

Backend API CI/CD

Currently, Ask Astro uses Google cloud run to run the API server, and deploys the backend API with cloud build. You can find the cloud build configuration in /api/cloudbuild.yaml.

Create cloud run service

These steps create a cloud service and template for your cloud build on the Google Cloud Platform.

  1. Go to https://console.cloud.google.com/, and search for the Cloud Run service.
  2. On the Cloud Run page, click on CREATE SERVICE.

create cloud run service

  1. Select Continuously deploy new revision from source repository and Set up with cloud build
  2. Select Repository provider as GitHub and click Next.

create cloud build config

  1. Set up the build configuration:
    • Branch name: main
    • Build type: Python via buildpacks
    • Build context directory: /api

create cloud build config

  1. Add Service name, Region, CPU allocation and pricing, Autoscaling, and Ingress.

create cloud build config

  1. Allow Unauthenticated invocation and click on Create.

create cloud build config

  1. Add the required Environment variables to run the backend API.
    1. After you create the service, visit the Created service page
    2. Click on EDIT AND DEPLOY NEW REVISION
    3. Add you Environment variable and click Deploy

cloud run edit

create cloud build config

Update cloud build configuration

  1. Go to https://console.cloud.google.com/ and search for the cloud build service.

cloud build trigger

  1. Click on Triggers. When you created a Cloud Run Service, it also made a Cloud Trigger Template that you can edit.

  2. Click on the cloud build trigger template and update the following information:

    1. Name, Description, Tag, and Event cloud build config1
    2. Select your Source and Branch. cloud build config2
    3. In Configuration, select Cloud Build configuration file and define the Cloud Build configuration file location as api/cloudbuild.yaml.
    4. Don't make any changes to the advance settings and click Save. cloud build config3
  3. In settings, enable Cloud build and Cloud run.

cloud build setting