This repository is for demonstration purposes only as part of a talk I give with the same title. You can use this repository to follow along with my talk and deploy your first app to Cloud Run using Cloud Build.
- Signup for a Github account if you don't already have one.
- In the top-right corner of the page, click Fork.
- Under "Owner," select the dropdown menu and click an owner for the forked repository.
- By default, forks are named the same as their upstream repositories. Optionally, to further distinguish your fork, in the "Repository name" field, type a name.
- In the Google Cloud console, go to Menu menu > IAM & Admin > Create a Project.
- In the Project Name field, enter a descriptive name for your project. Optional: To edit the Project ID, click Edit. The project ID can't be changed after the project is created, so choose an ID that meets your needs for the lifetime of the project.
- In the Location field, click Browse to display potential locations for your project. Then, click Select.
- Click Create. The console navigates to the Dashboard page and your project is created within a few minutes.
- Create and deploy a new Service on Cloud Run by following these instructions
- In the Google Cloud console, go to Menu > Cloud Run > Create service.
- In the form, select Continuously deploy new revisions from a source repository
- In the Service settings page, click Set up with Cloud Build (enable the necessary API(s) if prompted)
- Select GitHub as the Provider. If you are not yet authenticated, click Authenticate and follow the instructions.
- Select the Repository.
- Click Next.
- Enter the Branch to indicate what source should be used when running the trigger. You can use a regex. (You can just use main for this demo)
- Select the Google Cloud Buildpacks Build Type option
- Click Save
- Enter a Service name
- Select Allow unauthenticated invocations as the Authentication
- Click Create
- In the Google Cloud console, go to Menu > Cloud Run
- Click on the name of your service.
- Copy the URL for your service
- Open a new browser tab and paste the URL followed by ?numerator=150&denominator=10 then hit Enter to visit the URL.
- You should see JSON output displaying the numerator, denominator and the result of doing the division.
- Try different values. You should receive an Internal Server Error when not specifying values or specifying one as 0.
- Back on your Service Details in the Google Cloud Console, click the LOGS link to confirm that your Error was logged.
- Using either your preferred IDE or directly in GitHub, make the changes specified in the TODOs in index.js.
- Commit the changes to the same branch you specified in Build a new Cloud Run Service.
- In the Google Cloud console, go to Menu > Cloud Build > History.
- You should see the build just triggered by your commit.
- Click into the build to view the steps execute.
- Once the build has completed successfully, repeat the steps previously performed in Testing our App.
- You should now receive valid JSON when testing with a 0 denominator.
- In the Google Cloud console, go to Menu > Cloud Run
- Click on the name of your service.
- Click the plus icon in the Revision URLs (tags) column for the second revision in the list
- Enter error as the Tag name 1
- Click Save
- Click on the link to open the new Revision URL. The Internal Server Error should appear.
- Confirm the Internal Server Error does not appear when visiting the URL for the service at the top of the page