Configure Cloud Run and Cloud Functions services

Use the following environment variables to configure the behavior of your services when deployed to either Cloud Run or Cloud Functions.

Learn how to set these environment variable in your container image.

For configuration details about a specific language, see:

Cloud Run and Cloud Functions environment variables

The following configurations support building services for both applications and functions. Also see the additional Cloud Functions environment variables below.

GOOGLE_ENTRYPOINT

Specifies the command that is run when your container is executed. This is equivalent to entrypoint in a Dockerfile.

  • Examples:
    • Java: java -jar target/myjar.jar
    • PHP: php -S 0.0.0.0:8080 index.php
    • Python: gunicorn -p :8080 main:app

GOOGLE_RUNTIME

Forces the runtime to opt-in. If the runtime buildpack image appears in multiple groups, the buildpack image in the first group is used across all groups.

Node.js example: Specifying nodejs forces the Node.js runtime buildpack to opt-in.

GOOGLE_RUNTIME_VERSION

Specifies the version of your runtime to install. For .NET, specifies the .NET SDK version.

Examples:

  • Go: 1.14.1
  • Java: 8
  • Node.js: 13.7.0
  • .NET: 3.1.301

GOOGLE_BUILDABLE

For Go, Java, Dart, and .NET runtimes: Specifies path to a buildable unit.

Go example: Specifying ./maindir builds the package rooted at maindir.

GOOGLE_BUILD_ARGS

For Java (Maven and Gradle) and .NET runtimes: Appends arguments to the build command.

Java example: Specifying -Pprod runs mvn clean package ... -Pprod.

GOOGLE_MAVEN_BUILD_ARGS

For Java runtimes using the Maven plugin: Overrides the default Maven command with the build command that you specify.

When GOOGLE_MAVEN_BUILD_ARGS is not specified, the following command is run by default:

mvn clean package --batch-mode -DskipTests -Dhttp.keepAlive=false

Example: Specifying GOOGLE_MAVEN_BUILD_ARGS="clean package: runs the mvn clean package command.

GOOGLE_GRADLE_BUILD_ARGS

For Java runtimes using the Gradle plugin: Overrides the default Gradle command with the build command that you specify.

When GOOGLE_GRADLE_BUILD_ARGS is not specified, the following command is run by default:

gradle clean assemble -x test --build-cache

Example: Specifying GOOGLE_GRADLE_BUILD_ARGS="clean assemble" runs the gradle clean assemble command.

GOOGLE_DEVMODE

For Skaffold: Enables the development mode buildpacks. Use live local development to trigger automatic container rebuilds for changes to your source code. You must install Skaffold and run skaffold dev.

  • Supported values: true, True, 1

GOOGLE_CLEAR_SOURCE

For functions and Go or Java applications: Clears source after the application is built. If the application depends on static files, such as Go templates, setting this variable may cause the application to misbehave.

Supported values: true, True, or 1

Additional Cloud Functions environment variables

The following configurations are only available for source code built as functions that use Functions Framework and Cloud Functions. For more information about these configuration option, see the contract.

GOOGLE_FUNCTION_TARGET

  • Specifies the name of the exported function to be invoked in response to requests.
  • Example: myFunction will cause the Functions Framework to invoke the function of the same name.

GOOGLE_FUNCTION_SIGNATURE_TYPE

  • Specifies the signature used by the function.
  • Example: http, event, or cloudevent.

GOOGLE_FUNCTION_SOURCE

  • Specifies the name of the directory or file containing the function source, depending on the language.
  • (Only applicable to some languages, please see the language-specific documentation.)
  • Example: function.py for Python.