
If you have a public repository with a Dockerfile you can have users automatically deploy the container to Google Cloud Run by adding a Cloud Run Button. It’s no more than an image that links to https://deploy.cloud.run, like so:
[](https://deploy.cloud.run)
Add that code to your README.md and when a visitor follows that link, Cloud Shell will open and it will Clone, Build, and Deploy the project onto Cloud Run for them. No need to manually create things in the Google Cloud Console nor use the gcloud binary 🙂

You basically only need the button, but you can tweak the source repository parameters through the querystring:
- When no parameters are passed, the referer is used to detect the git repo and branch
- To specify a git repo, add a
git_repo=URLquery parameter- To specify a git branch, add a
revision=BRANCH_NAMEquery parameter.- To run the build in a subdirectory of the repo, add a
dir=SUBDIRquery parameter.
There’s also an app.json that you can optionally add to the root of your repo to tweak the deployment parameters.
{
"name": "foo-app",
"env": {
"BACKGROUND_COLOR": {
"description": "specify a css color",
"value": "#fefefe",
"required": false
},
"TITLE": {
"description": "title for your site"
},
"APP_SECRET": {
"generator": "secret"
}
},
"options": {
"allow-unauthenticated": false
},
"hooks": {
"precreate": {
"commands": [
"echo 'test'"
]
},
"postcreate": {
"commands": [
"./setup.sh"
]
}
}
}
The values defined in the env key will be translated to prompts for Cloud Shell to ask. The props of each prompt is pretty straightforward but the special case of "generator": "secret" will ask/generate a secret.
By default it will deploy with allow-unauthenticated set to true but through the options you can override that.
The hooks part finally allows you to run commands in separate bash shells with the environment variables configured for the application and environment variables for GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_REGION, and K_SERVICE.
~
Thank me with a coffee.
I don’t do this for profit but a small one-time donation would surely put a smile on my face. Thanks!
To stay in the loop you can follow bramus on Bluesky or subscribe to the RSS feed.