11# How-to Guide: Deploy a C++ Pub/Sub function to Cloud Run
22
3- [ repository-gh ] : https://github.com/GoogleCloudPlatform/functions-framework-cpp
4- [ howto-create-container ] : /examples/site/howto_create_container/README.md
5- [ cloud-run-quickstarts ] : https://cloud.google.com/run/docs/quickstarts
6- [ gcp-quickstarts ] : https://cloud.google.com/resource-manager/docs/creating-managing-projects
7- [ buildpacks ] : https://buildpacks.io
8- [ docker ] : https://docker.com/
9- [ docker-install ] : https://store.docker.com/search?type=edition&offering=community
10- [ sudoless docker ] : https://docs.docker.com/engine/install/linux-postinstall/
11- [ pack-install ] : https://buildpacks.io/docs/install-pack/
12- [ hello-world-pubsub ] : /examples/site/hello_world_pubsub/hello_world_pubsub.cc
13- [ gcloud-eventarc-create ] : https://cloud.google.com/sdk/gcloud/reference/beta/eventarc/triggers/create
14-
153## Pre-requisites
164
175This guide assumes you are familiar with Google Cloud, and that you have a GCP
@@ -79,33 +67,26 @@ clone:
7967cd $HOME /functions-framework-cpp
8068```
8169
82- ## Setting up the buildpacks builder
83-
84- We will be using a [ buildpacks] [ buildpacks ] builder to create the container
85- image deployed to Cloud Run. The first time your run these commands it can take
86- several minutes, maybe as long as an hour, depending on your workstation's
87- performance.
88-
89- ``` sh
90- docker build -t gcf-cpp-run-image --target gcf-cpp-runtime -f build_scripts/Dockerfile build_scripts
91- docker build -t gcf-cpp-build-image --target gcf-cpp-develop -f build_scripts/Dockerfile .
92- pack builder create gcf-cpp-builder:bionic --config pack/builder.toml
93- pack config trusted-builders add gcf-cpp-builder:bionic
94- pack config default-builder gcf-cpp-builder:bionic
95- ```
96-
9770## Building a Docker image
9871
72+ > :warning: This will automatically download and compile the functions
73+ > framework and all its dependencies. Consequently, the first build of a
74+ > function may take several minutes (and up to an hour) depending on the
75+ > performance of your workstation. Subsequent builds cache many binary
76+ > artifacts, but these caches are * not* shared across functions, so plan
77+ > accordingly.
78+
9979Set the ` GOOGLE_CLOUD_PROJECT ` shell variable to the project id of your GCP
100- project, and create a docker image with your function:
80+ project, and use the [ Google Cloud buildpack] builder to create a docker image
81+ containing your function:
10182
10283``` shell
10384GOOGLE_CLOUD_PROJECT=... # put the right value here
10485pack build \
105- --builder gcf-cpp- builder:bionic \
106- --env FUNCTION_SIGNATURE_TYPE =cloudevent \
107- --env TARGET_FUNCTION =hello_world_pubsub \
108- --path examples/site/hello_world_pubsub \
86+ --builder gcr.io/buildpacks/ builder:latest \
87+ --env GOOGLE_FUNCTION_SIGNATURE_TYPE =cloudevent \
88+ --env GOOGLE_FUNCTION_TARGET =hello_world_pubsub \
89+ --path examples/site/hello_world_pubsub \
10990 " gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-cpp-hello-world-pubsub"
11091```
11192
@@ -193,6 +174,14 @@ gcloud logging read \
193174
194175## Cleanup
195176
177+ Delete the trigger:
178+
179+ ``` shell
180+ gcloud beta eventarc triggers delete gcf-cpp-hello-world-pubsub-trigger \
181+ --project=" ${GOOGLE_CLOUD_PROJECT} " \
182+ --location=" us-central1"
183+ ```
184+
196185Delete the Cloud Run deployment:
197186
198187``` sh
@@ -208,3 +197,16 @@ And the container image:
208197gcloud container images delete \
209198 " gcr.io/${GOOGLE_CLOUD_PROJECT} /gcf-cpp-hello-world-pubsub:latest"
210199```
200+
201+ [ repository-gh ] : https://github.com/GoogleCloudPlatform/functions-framework-cpp
202+ [ howto-create-container ] : /examples/site/howto_create_container/README.md
203+ [ cloud-run-quickstarts ] : https://cloud.google.com/run/docs/quickstarts
204+ [ gcp-quickstarts ] : https://cloud.google.com/resource-manager/docs/creating-managing-projects
205+ [ buildpacks ] : https://buildpacks.io
206+ [ docker ] : https://docker.com/
207+ [ docker-install ] : https://store.docker.com/search?type=edition&offering=community
208+ [ sudoless docker ] : https://docs.docker.com/engine/install/linux-postinstall/
209+ [ pack-install ] : https://buildpacks.io/docs/install-pack/
210+ [ hello-world-pubsub ] : /examples/site/hello_world_pubsub/hello_world_pubsub.cc
211+ [ gcloud-eventarc-create ] : https://cloud.google.com/sdk/gcloud/reference/beta/eventarc/triggers/create
212+ [ Google Cloud buildpack ] : https://github.com/GoogleCloudPlatform/buildpacks
0 commit comments