Google Cloud Run Speedrun
1. setup Google Cloud Run
click Connect Repo
choose your repository and select Dockerfile; choose your git branch
use reasonable service name and region
select request-based billing
set auto-scaling from 0 to a small number (no need for 100), save budget
1.0 You need a working Dockerfile
template:
1 | # Use the official lightweight Python image |
2. trigger by tag instead of commit
2.0 the setup
click edit repo settings
in Event, select Push new tag
set Tag to ^v.*$, so that when a new tag like v1.0.1, v0.2.1 is tagged in the newest commit, build will be triggered
2.1 push with tags
1 | git tag v1.0.0 # set tag to current commit or right click on current commit on VScode |
then a new build is triggered.
3. if you use google cloud storage
3.0 create a service account
goto IAM&Admin, left panel Service Account, click Create Service Account
give reasonable name
grant role of Storage Object Admin or other role you prefer
click on action ..., manage keys, and download the json key (keep it secure)