If you have a public repository, you can add this button to your README.md
and
let anyone deploy your application to Google Cloud Run with a single
click.
Try it out with a "hello, world" Go application (source):
-
Copy & paste this markdown:
[![Run on Google Cloud](https://deploy.cloud.run/button.svg)](https://deploy.cloud.run)
-
If the repo contains a
Dockerfile
, it will be built using thedocker build
command. If the repo uses Maven for the build and it contains the Jib plugin, then the container image will be built with Jib (Jib Spring Boot Sample). Otherwise, CNCF Buildpacks (i.e. thepack build
command) will attempt to build the repo (buildpack samples). Alternatively, you can skip these built-in build methods using thebuild.skip
field (see below) and use aprebuild
orpostbuild
hook to build the container image yourself.
- 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=URL
query parameter - To specify a git branch, add a
revision=BRANCH_NAME
query parameter. - To run the build in a subdirectory of the repo, add a
dir=SUBDIR
query parameter.
If you include an app.json
at the root of your repository, it allows you
customize the experience such as defining an alternative service name, or
prompting for additional environment variables.
For example, a fully populated app.json
file looks like this:
{
"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"
},
"ORDERED_ENV": {
"description": "control the order env variables are prompted",
"order": 100
}
},
"options": {
"allow-unauthenticated": false,
"memory": "512Mi",
"cpu": "1",
"port": 80,
"http2": false,
"concurrency": 80,
"max-instances": 10
},
"build": {
"skip": false,
"buildpacks": {
"builder": "some/builderimage"
}
},
"hooks": {
"prebuild": {
"commands": [
"./my-custom-prebuild"
]
},
"postbuild": {
"commands": [
"./my-custom-postbuild"
]
},
"precreate": {
"commands": [
"echo 'test'"
]
},
"postcreate": {
"commands": [
"./setup.sh"
]
}
}
}
Reference:
name
: (optional, default: repo name, or sub-directory name if specified) Name of the Cloud Run service and the built container image. Not validated for naming restrictions.env
: (optional) Prompt user for environment variables.description
: (optional) short explanation of what the environment variable does, keep this short to make sure it fits into a line.value
: (optional) default value for the variable, should be a string.required
, (optional, default:true
) indicates if they user must provide a value for this variable.generator
, (optional) use a generator for the value, currently only supportsecret
order
, (optional) if specified, used to indicate the order in which the variable is prompted to the user. If some variables specify this and some don't, then the unspecified ones are prompted last.
options
: (optional) Options when deploying the serviceallow-unauthenticated
: (optional, default:true
) allow unauthenticated requestsmemory
: (optional) memory for each instancecpu
: (optional) cpu for each instanceport
: (optional) if your application doesn't respect the PORT environment variable provided by Cloud Run, specify the port number it listens onhttp2
: (optional) use http2 for the connectionconcurrency
: (optional) concurrent requests for each instancemax-instances
: (optional) autoscaling limit (max 1000)
build
: (optional) Build configurationskip
: (optional, default:false
) skips the built-in build methods (docker build
,Maven Jib
, andbuildpacks
), but still allows forprebuild
andpostbuild
hooks to be run in order to build the container image manuallybuildpacks
: (optional) buildpacks config (Note: Additional Buildpack config can be specified using aproject.toml
file. See the spec for details.)builder
: (optional, default:gcr.io/buildpacks/builder:v1
) overrides the buildpack builder image
hooks
: (optional) Run commands in separate bash shells with the environment variables configured for the application and environment variablesGOOGLE_CLOUD_PROJECT
(Google Cloud project),GOOGLE_CLOUD_REGION
(selected Google Cloud Region),K_SERVICE
(Cloud Run service name),IMAGE_URL
(container image URL),APP_DIR
(application directory). Command outputs are shown as they are executed.prebuild
: (optional) Runs the specified commands before running the built-in build methods. Use theIMAGE_URL
environment variable to determine the container image name you need to build.commands
: (array of strings) The list of commands to run
postbuild
: (optional) Runs the specified commands after running the built-in build methods. Use theIMAGE_URL
environment variable to determine the container image name you need to build.commands
: (array of strings) The list of commands to run
precreate
: (optional) Runs the specified commands before the service has been createdcommands
: (array of strings) The list of commands to run
postcreate
: (optional) Runs the specified commands after the service has been created; theSERVICE_URL
environment variable provides the URL of the deployed Cloud Run servicecommands
: (array of strings) The list of commands to run
- Disclaimer: This is not an officially supported Google product.
- See LICENSE for the licensing information.
- See Contribution Guidelines on how to contribute.