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 the docker 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. the pack build
command) will attempt to build the repo
(buildpack samples). Alternatively, you can skip these built-in build methods using the
build.skip
field (see below) and use a prebuild
or postbuild
hook to build the container image yourself.
git_repo=URL
query parameterrevision=BRANCH_NAME
query parameter.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 support secret
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 service
allow-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 configuration
skip
: (optional, default: false
) skips the built-in build methods (docker build
, Maven Jib
, and
buildpacks
), but still allows for prebuild
and postbuild
hooks to be run in order to build the container image
manuallybuildpacks
: (optional) buildpacks config (Note: Additional Buildpack config can be specified using a project.toml
file. See the spec for details.)builder
: (optional, default: gcr.io/buildpacks/builder:v1
) overrides the buildpack builder imagehooks
: (optional) Run commands in separate bash shells with the environment variables configured for the
application and environment variables GOOGLE_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 the IMAGE_URL
environment variable to determine the container image name you need to build.commands
: (array of strings) The list of commands to runpostbuild
: (optional) Runs the specified commands after running the built-in build methods. Use the IMAGE_URL
environment variable to determine the container image name you need to build.commands
: (array of strings) The list of commands to runprecreate
: (optional) Runs the specified commands before the service has been createdcommands
: (array of strings) The list of commands to runpostcreate
: (optional) Runs the specified commands after the service has been created; the SERVICE_URL
environment variable provides the URL of the deployed Cloud Run servicecommands
: (array of strings) The list of commands to run