Skip to content

Commit cd58ccf

Browse files
authored
Merge 2e2d898 into c7e8829
2 parents c7e8829 + 2e2d898 commit cd58ccf

File tree

7 files changed

+109
-124
lines changed

7 files changed

+109
-124
lines changed

examples/site/howto_create_container/README.md

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
# How-to Guide: Running your function as Docker container
22

3-
[repository-gh]: https://github.com/GoogleCloudPlatform/functions-framework-cpp
4-
[buildpacks]: https://buildpacks.io
5-
[docker]: https://docker.com/
6-
[docker-install]: https://store.docker.com/search?type=edition&offering=community
7-
[sudoless docker]: https://docs.docker.com/engine/install/linux-postinstall/
8-
[pack-install]: https://buildpacks.io/docs/install-pack/
9-
[hello-world-http]: /examples/site/hello_world_http/hello_world_http.cc
10-
113
This guide shows you how to create a container image for an example function,
124
and how to run said image in a local container on your workstation.
135

@@ -75,30 +67,23 @@ clone:
7567
cd $HOME/functions-framework-cpp
7668
```
7769

78-
## Setting up the buildpacks builder
79-
80-
We will be using a [buildpacks][buildpacks] builder to create the container
81-
image deployed to Cloud Run. The first time your run these commands it can take
82-
several minutes, maybe as long as an hour, depending on your workstation's
83-
performance.
84-
85-
```sh
86-
docker build -t gcf-cpp-run-image --target gcf-cpp-runtime -f build_scripts/Dockerfile build_scripts
87-
docker build -t gcf-cpp-build-image --target gcf-cpp-develop -f build_scripts/Dockerfile .
88-
pack builder create gcf-cpp-builder:bionic --config pack/builder.toml
89-
pack config trusted-builders add gcf-cpp-builder:bionic
90-
pack config default-builder gcf-cpp-builder:bionic
91-
```
92-
9370
## Building a Docker image
9471

95-
Build a Docker image from your function using this buildpack:
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+
79+
We use the [Google Cloud buildpack] builder to create the Docker image
80+
containing your function:
9681

9782
```shell
9883
pack build \
99-
--builder gcf-cpp-builder:bionic \
100-
--env FUNCTION_SIGNATURE_TYPE=http \
101-
--env TARGET_FUNCTION=hello_world_http \
84+
--builder gcr.io/buildpacks/builder:latest \
85+
--env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \
86+
--env GOOGLE_FUNCTION_TARGET=hello_world_http \
10287
--path examples/site/hello_world_http \
10388
gcf-cpp-hello-world-http
10489
```
@@ -133,4 +118,13 @@ And delete the local image:
133118

134119
```shell
135120
docker image rm gcf-cpp-hello-world-http
136-
```
121+
```
122+
123+
[repository-gh]: https://github.com/GoogleCloudPlatform/functions-framework-cpp
124+
[buildpacks]: https://buildpacks.io
125+
[docker]: https://docker.com/
126+
[docker-install]: https://store.docker.com/search?type=edition&offering=community
127+
[sudoless docker]: https://docs.docker.com/engine/install/linux-postinstall/
128+
[pack-install]: https://buildpacks.io/docs/install-pack/
129+
[hello-world-http]: /examples/site/hello_world_http/hello_world_http.cc
130+
[Google Cloud buildpack]: https://github.com/GoogleCloudPlatform/buildpacks

examples/site/howto_deploy_cloud_event/README.md

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
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

175
This guide assumes you are familiar with Google Cloud, and that you have a GCP
@@ -79,33 +67,26 @@ clone:
7967
cd $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+
9979
Set 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
10384
GOOGLE_CLOUD_PROJECT=... # put the right value here
10485
pack 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+
196185
Delete the Cloud Run deployment:
197186

198187
```sh
@@ -208,3 +197,16 @@ And the container image:
208197
gcloud 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

examples/site/howto_deploy_to_cloud_run/README.md

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,33 +81,26 @@ clone:
8181
cd $HOME/functions-framework-cpp
8282
```
8383

84-
## Setting up the buildpacks builder
85-
86-
We will be using a [buildpacks][buildpacks] builder to create the container
87-
image deployed to Cloud Run. The first time your run these commands it can take
88-
several minutes, maybe as long as an hour, depending on your workstation's
89-
performance.
90-
91-
```sh
92-
docker build -t gcf-cpp-run-image --target gcf-cpp-runtime -f build_scripts/Dockerfile build_scripts
93-
docker build -t gcf-cpp-build-image --target gcf-cpp-develop -f build_scripts/Dockerfile .
94-
pack builder create gcf-cpp-builder:bionic --config pack/builder.toml
95-
pack config trusted-builders add gcf-cpp-builder:bionic
96-
pack config default-builder gcf-cpp-builder:bionic
97-
```
98-
9984
## Building a Docker image
10085

86+
> :warning: This will automatically download and compile the functions
87+
> framework and all its dependencies. Consequently, the first build of a
88+
> function may take several minutes (and up to an hour) depending on the
89+
> performance of your workstation. Subsequent builds cache many binary
90+
> artifacts, but these caches are *not* shared across functions, so plan
91+
> accordingly.
92+
10193
Set the `GOOGLE_CLOUD_PROJECT` shell variable to the project id of your GCP
102-
project, and create a docker image with your function:
94+
project, and use the [Google Cloud buildpack] builder to create a docker image
95+
containing your function:
10396

10497
```shell
10598
GOOGLE_CLOUD_PROJECT=... # put the right value here
10699
pack build \
107-
--builder gcf-cpp-builder:bionic \
108-
--env FUNCTION_SIGNATURE_TYPE=http \
109-
--env TARGET_FUNCTION=hello_world_http \
110-
--path examples/site/hello_world_http \
100+
--builder gcr.io/buildpacks/builder:latest \
101+
--env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \
102+
--env GOOGLE_FUNCTION_TARGET=hello_world_http \
103+
--path examples/site/hello_world_http \
111104
"gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-cpp-hello-world-http"
112105
```
113106

examples/site/howto_local_development/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
# How-to Guide: Local Development
22

3-
[vcpkg-gh]: https://github.com/microsoft/vcpkg
4-
[vcpkg-install]: https://github.com/microsoft/vcpkg#getting-started
5-
[cmake]: https://cmake.org
6-
[cmake-install]: https://cmake.org/install/
7-
83
This guide describes how to compile and run a function locally. This can be
94
useful when writing unit test, or to accelerate the edit -> compile -> test
105
cycle.
@@ -134,3 +129,8 @@ curl http://localhost:8080
134129
```
135130

136131
You can just interrupt (`Ctrl-C`) the program to terminate it.
132+
133+
[vcpkg-gh]: https://github.com/microsoft/vcpkg
134+
[vcpkg-install]: https://github.com/microsoft/vcpkg#getting-started
135+
[cmake]: https://cmake.org
136+
[cmake-install]: https://cmake.org/install/

examples/site/howto_offload_builder_creation/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
# How-to Guide: Use Cloud Build to create a buildpacks builder
22

3-
[repository-gh]: https://github.com/GoogleCloudPlatform/functions-framework-cpp
4-
[cloud-build-quickstarts]: https://cloud.google.com/build/docs/quickstarts
5-
[gcp-quickstarts]: https://cloud.google.com/resource-manager/docs/creating-managing-projects
6-
[buildpacks]: https://buildpacks.io
7-
[docker]: https://docker.com/
8-
[docker-install]: https://store.docker.com/search?type=edition&offering=community
9-
[sudoless docker]: https://docs.docker.com/engine/install/linux-postinstall/
10-
[pack-install]: https://buildpacks.io/docs/install-pack/
11-
[hello-world-http]: /examples/site/hello_world_http/hello_world_http.cc
12-
[cloud-build]: https://cloud.google.com/cloud-build
13-
143
This guide shows you how to use [Cloud Build][cloud-build] to offload the
154
creation of [buildpacks] builders.
165

@@ -145,3 +134,14 @@ for image in \
145134
xargs gcloud container images delete --force-delete-tags
146135
done
147136
```
137+
138+
[repository-gh]: https://github.com/GoogleCloudPlatform/functions-framework-cpp
139+
[cloud-build-quickstarts]: https://cloud.google.com/build/docs/quickstarts
140+
[gcp-quickstarts]: https://cloud.google.com/resource-manager/docs/creating-managing-projects
141+
[buildpacks]: https://buildpacks.io
142+
[docker]: https://docker.com/
143+
[docker-install]: https://store.docker.com/search?type=edition&offering=community
144+
[sudoless docker]: https://docs.docker.com/engine/install/linux-postinstall/
145+
[pack-install]: https://buildpacks.io/docs/install-pack/
146+
[hello-world-http]: /examples/site/hello_world_http/hello_world_http.cc
147+
[cloud-build]: https://cloud.google.com/cloud-build

examples/site/testing_pubsub/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# How-to Guide: Testing Event-driven Functions (Pub/Sub triggered)
22

3-
[buildpacks]: https://buildpacks.io
4-
[boost-log-gh]: https://github.com/boostorg/log
5-
[/examples/site/hello_world_pubsub/hello_world_pubsub.cc]: /examples/site/hello_world_pubsub/hello_world_pubsub.cc
6-
[pubsub_unit_test.cc]: pubsub_unit_test.cc
7-
[pubsub_integration_server.cc]: pubsub_integration_server.cc
8-
[pubsub_integration_test.cc]: pubsub_integration_test.cc
9-
[quickstart-guide]: /examples/site/howto_local_development/README.md
10-
[container-guide]: /examples/site/howto_create_container/README.md
11-
[pubsub-quickstart]: https://cloud.google.com/pubsub/docs/quickstart-console
12-
133
Event-driven functions do not return values, their only observable behavior are
144
side-effects. All tests, therefore, are looking at the side-effects of these
155
functions. Depending on where the function is deployed this might be more or
@@ -117,3 +107,13 @@ env "GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT}" \
117107
"SERVICE_ID=gcf-hello-world-pubsub" \
118108
./pubsub_system_test # use actual path to binary
119109
```
110+
111+
[buildpacks]: https://buildpacks.io
112+
[boost-log-gh]: https://github.com/boostorg/log
113+
[/examples/site/hello_world_pubsub/hello_world_pubsub.cc]: /examples/site/hello_world_pubsub/hello_world_pubsub.cc
114+
[pubsub_unit_test.cc]: pubsub_unit_test.cc
115+
[pubsub_integration_server.cc]: pubsub_integration_server.cc
116+
[pubsub_integration_test.cc]: pubsub_integration_test.cc
117+
[quickstart-guide]: /examples/site/howto_local_development/README.md
118+
[container-guide]: /examples/site/howto_create_container/README.md
119+
[pubsub-quickstart]: https://cloud.google.com/pubsub/docs/quickstart-console

examples/site/testing_storage/README.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
# How-to Guide: Testing Event-driven Functions (Cloud Audit Log triggered)
2-
3-
> :warning: this example depends on features in the upcoming release 0.4.0.
4-
> until that release is cut, the default builders will link against 0.3.0
5-
> and this example will not work correctly.
6-
7-
[buildpacks]: https://buildpacks.io
8-
[boost-log-gh]: https://github.com/boostorg/log
9-
[/examples/site/hello_world_storage/hello_world_storage.cc]: /examples/site/hello_world_storage/hello_world_storage.cc
10-
[storage_unit_test.cc]: storage_unit_test.cc
11-
[storage_integration_server.cc]: storage_integration_server.cc
12-
[storage_integration_test.cc]: storage_integration_test.cc
13-
[quickstart-guide]: /examples/site/howto_local_development/README.md
14-
[container-guide]: /examples/site/howto_create_container/README.md
15-
[pubsub-quickstart]: https://cloud.google.com/pubsub/docs/quickstart-console
1+
# How-to Guide: Testing Event-driven Functions
162

173
Event-driven functions do not return values, therefore, their only observable
184
behavior are their side-effects and any testing for them is based in observing
@@ -75,9 +61,9 @@ We will create a container for the storage "hello world" function as usual:
7561
7662
```shell
7763
pack build \
78-
--builder gcf-cpp-builder:bionic \
79-
--env "FUNCTION_SIGNATURE_TYPE=cloudevent" \
80-
--env "TARGET_FUNCTION=hello_world_storage" \
64+
--builder gcr.io/buildpacks/builder:latest \
65+
--env "GOOGLE_FUNCTION_SIGNATURE_TYPE=cloudevent" \
66+
--env "GOOGLE_FUNCTION_TARGET=hello_world_storage" \
8167
--path "examples/site/hello_world_storage" \
8268
"gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-hello-world-storage"
8369
```
@@ -144,3 +130,13 @@ gcloud run services delete gcf-cpp-hello-world-storage \
144130
gcloud container images delete \
145131
"gcr.io/${GOOGLE_CLOUD_PROJECT}/gcf-cpp-hello-world-storage:latest"
146132
```
133+
134+
[buildpacks]: https://buildpacks.io
135+
[boost-log-gh]: https://github.com/boostorg/log
136+
[/examples/site/hello_world_storage/hello_world_storage.cc]: /examples/site/hello_world_storage/hello_world_storage.cc
137+
[storage_unit_test.cc]: storage_unit_test.cc
138+
[storage_integration_server.cc]: storage_integration_server.cc
139+
[storage_integration_test.cc]: storage_integration_test.cc
140+
[quickstart-guide]: /examples/site/howto_local_development/README.md
141+
[container-guide]: /examples/site/howto_create_container/README.md
142+
[pubsub-quickstart]: https://cloud.google.com/pubsub/docs/quickstart-console

0 commit comments

Comments
 (0)