Step 2: Create a Cloud Run service

This guide shows you how to create a Cloud Run service and configure a Cloud Build trigger for continuous deployment.

Create a Cloud Run service with continuous build

  1. In the Google Cloud console, go to the Cloud Run page.

    Go to Cloud Run

  2. Click Create service.

  3. Select Continuously deploy from a repository.

  4. Click Set up with Cloud Build.

  5. In the Repository list, select the forked GitHub repository that you created for your app.

    If your repository isn't listed, click Manage connected repositories. If prompted, do the following:

    • Authenticate to GitHub.
    • Install Cloud Build on your GitHub account.
  6. If this is the first time you are using a repository with Cloud Build in this project, select the checkbox to agree to the terms of use policy.

  7. Click Next.

  8. In the Build configuration section, enter the following details:

    • Branch: The default branch is ^main$. Don't update this.
    • Build type: Click Dockerfile.
    • Source location: Enter the following:

      /gemini/sample-apps/gemini-streamlit-cloudrun/Dockerfile
      
  9. Click Save.

  10. On the Create service page, in the Configure section, enter the following details:

    • Service name: Enter gemini-streamlit-cloudrun.
    • Authentication: Click Allow unauthenticated invocations.
  11. Click Container(s), volumes, networking, security.

  12. In the Revision autoscaling section, enter the following:

    • Minimum number of instances: Enter 1.
    • Maximum number of instances: Enter 3.
  13. Click Create.

  14. Optional: To test the app deployment to Cloud Run, do the following:

    1. On the Services page in Cloud Run, click the service name.

      Go to the Services page

    2. On the Service details page, click the URL displayed next to the service name.

Set up an automatic Cloud Build trigger

  1. In Cloud Build, go to the Triggers page.

    Go to the Triggers page

  2. Click the name of your new trigger.

  3. Under Source, click Show included and ignored files filters.

  4. In the Included files filter box, enter gemini-streamlit-cloudrun/**.

  5. Click Save.