You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Use `npm start` to start the built-in local development server:
107
+
108
+
```sh
109
+
npm start
110
+
...
111
+
Serving function...
112
+
Function: helloWorld
113
+
URL: http://localhost:8080/
114
+
```
115
+
116
+
1. Send requests to thisfunction using `curl` from another terminal window:
117
+
118
+
```sh
119
+
curl localhost:8080
120
+
# Output: Hello, World
121
+
```
122
+
123
+
### Quickstart: Build a Deployable Container
124
+
125
+
1. Install [Docker](https://store.docker.com/search?type=edition&offering=community) and the [`pack` tool](https://buildpacks.io/docs/install-pack/).
126
+
127
+
1.Buildacontainerfromyourfunction using the Functions [buildpacks](https://github.com/GoogleCloudPlatform/buildpacks):
128
+
129
+
```sh
130
+
pack build \
131
+
--builder gcr.io/buildpacks/builder:v1 \
132
+
--env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \
133
+
--env GOOGLE_FUNCTION_TARGET=helloWorld \
134
+
my-first-function
135
+
```
136
+
137
+
1.Startthebuiltcontainer:
138
+
139
+
```sh
140
+
docker run --rm -p 8080:8080 my-first-function
141
+
# Output: Serving function...
142
+
```
143
+
144
+
1.Sendrequeststothisfunction using `curl` from another terminal window:
145
+
146
+
```sh
147
+
curl localhost:8080
148
+
# Output: Hello, World!
149
+
```
150
+
151
+
## Run your function on serverless platforms
152
+
153
+
### Google Cloud Functions
124
154
125
155
The
126
156
[Node.js 10 runtime on Google Cloud Functions](https://cloud.google.com/functions/docs/concepts/nodejs-10-runtime)
@@ -132,17 +162,17 @@ After you've written your function, you can simply deploy it from your local
132
162
machine using the `gcloud` command-line tool.
133
163
[Check out the Cloud Functions quickstart](https://cloud.google.com/functions/docs/quickstart).
134
164
135
-
## Cloud Run/Cloud Run on GKE
165
+
###CloudRun/CloudRunonGKE
136
166
137
167
Onceyou've written your function, added the Functions Framework and updated your `start` script in `package.json`, all that'sleftistocreateacontainerimage. [CheckouttheCloudRunquickstart](https://cloud.google.com/run/docs/quickstarts/build-and-deploy) for Node.js to create a container image and deploy it to Cloud Run. You'll write a `Dockerfile` when you build your container. This `Dockerfile` allows you to specify exactly what goes into your container (including custom binaries, a specific operating system, and more).
138
168
139
169
If you want even more control over the environment, you can [deploy your container image to Cloud Run on GKE](https://cloud.google.com/run/docs/quickstarts/prebuilt-deploy-gke). With Cloud Run on GKE, you can run your function on a GKE cluster, which gives you additional control over the environment (including use of GPU-based instances, longer timeouts and more).
140
170
141
-
## Container environments based on Knative
171
+
### Container environments based on Knative
142
172
143
173
Cloud Run and Cloud Run on GKE both implement the [Knative Serving API](https://www.knative.dev/docs/). The Functions Framework is designed to be compatible with Knative environments. Just build and deploy your container to a Knative environment.
144
174
145
-
# Configure the Functions Framework
175
+
## Configure the Functions Framework
146
176
147
177
You can configure the Functions Framework using command-line flags or
148
178
environment variables. If you specify both, the environment variable will be
@@ -164,7 +194,7 @@ For example:
164
194
}
165
195
```
166
196
167
-
# Enable Google Cloud Functions Events
197
+
## Enable Google Cloud Functions Events
168
198
169
199
The Functions Framework can unmarshall incoming
170
200
Google Cloud Functions [event](https://cloud.google.com/functions/docs/concepts/events-triggers#events) payloads to `data` and `context` objects.
@@ -186,7 +216,7 @@ For more details on this signature type, check out the Google Cloud Functions
0 commit comments