docs/versioned_docs/version-0.17.2/ci/integrations/google-cloud-run.mdx
import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem";
Dagger can be used to deploy any containerized application to Google Cloud Run. This allows developers to create continuous delivery pipelines that can be used both locally and in CI, and also run faster due to Dagger's intelligent caching. This integration does not require any installation of Google Cloud tools, such as the Google Cloud CLI or the Google Cloud SDKs.
The integration depends on the google-cloud-run Dagger module, which provides various Dagger Functions to create or update a Google Cloud Run service using a container image. These Dagger Functions make it easy to extend existing CI pipelines with additional deployment support.
To use this integration, you can call the Dagger module with the Dagger CLI directly, or you can create your own Dagger Function that uses it. In the latter case, you must:
google-cloud-run Dagger module as a dependencygoogle-cloud-run Dagger moduleThe following example demonstrates how to deploy a containerized application on Google Cloud Run using this integration.
The simplest option is to use the Dagger CLI to directly call the Dagger Function. Remember to update the project, location, image, http-port and credential arguments with the correct values and filesystem path.
dagger -m github.com/vvaswani/daggerverse/[email protected] call create-service \
--project=my-project \
--location=us-central1 \
--image=us-docker.pkg.dev/cloudrun/container/hello \
--http-port=3000 \
--credential=file://my-keyfile.json
If your requirements are more complex - for example, if you already have one or more Dagger Functions to build, test and containerize your application - you can install the google-cloud-run module as a dependency and call it from your existing Dagger Functions using code.
dagger init --name=my-module --sdk=go --source=./dagger
Install the Google Cloud Run module from the Daggerverse:
dagger install github.com/vvaswani/daggerverse/[email protected]
Update the generated dagger/main.go file with the following code:
dagger init --name=my-module --sdk=python --source=./dagger
Install the Google Cloud Run module from the Daggerverse:
dagger install github.com/vvaswani/daggerverse/[email protected]
Update the generated dagger/src/my_module/main.py file with the following code.
dagger init --name=my-module --sdk=typescript --source=./dagger
Install the Google Cloud Run module:
dagger install github.com/vvaswani/daggerverse/[email protected]
Update the generated dagger/src/index.ts file with the following code:
:::warning The code sample above is illustrative only. Modify it to your application's specific requirements. :::
Here is an example of calling the Dagger Function to deploy the Google Cloud sample application to Google Cloud Run. Remember to update the project-name, service-location, image-address and credential arguments with the correct values and filesystem path.
dagger call deploy \
--project-name=my-project \
--service-location=us-central1 \
--image-address=us-docker.pkg.dev/cloudrun/container/hello \
--service-port=3000 \
--credential=file://my-keyfile.json
:::tip
The google-cloud-run Dagger module can also modify an existing service by deploying a new container image to the service URL.
:::
If you have any questions about additional ways to use Google Cloud Run with Dagger, join our Discord and ask your questions in our help channel.
Google Cloud Run is a managed service to run containerized applications using Google Cloud.