Skip to content

Commit d4dec18

Browse files
committed
Update node version and syntax for faas-cli new
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent f2f119e commit d4dec18

File tree

10 files changed

+18
-29
lines changed

10 files changed

+18
-29
lines changed

docs/architecture/invocations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ Whenever you run `faas-cli build` or `faas-cli publish` using one of the OpenFaa
2222
Templates tend to abstract away the Dockerfile and entry-point HTTP server from you, so that you can focus on writing a HTTP or function handler, they are still there however and you can look into the "template" folder to find them after running `faas-cli template store pull`
2323

2424
```bash
25-
$ faas-cli template store pull node14
26-
$ ls template/node14
25+
$ faas-cli template store pull node20
26+
$ ls template/node20
2727
Dockerfile function index.js package.json template.yml
2828

29-
$ ls template/node14/
29+
$ ls template/node20/
3030
handler.js package.json
3131
```
3232

docs/cli/build.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export OPENFAAS_PREFIX=docker.io/alexellis2
6565

6666
faas-cli new --lang [email protected] \
6767
withprivate
68-
mv withprivate.yml stack.yml
6968
```
7069

7170
Next, set up a build secret, for instance to fetch Pip modules from a private PyPi repository:
@@ -153,9 +152,8 @@ Create a function:
153152

154153
```bash
155154
export OPENFAAS_PREFIX=openfaasltd
156-
faas-cli template store pull node17
157-
faas-cli new --lang node17 withprivatenpm
158-
mv withprivatenpm.yml stack.yml
155+
faas-cli template store pull node20
156+
faas-cli new --lang node20 withprivatenpm
159157
```
160158

161159
You will need to create an authentication token to install private npm modules. These instructions will differ depending on the registry you want to use:
@@ -188,7 +186,7 @@ provider:
188186
gateway: http://127.0.0.1:8080
189187
functions:
190188
withprivatenpm:
191-
lang: node17
189+
lang: node20
192190
handler: ./withprivatenpm
193191
image: openfaasltd/withprivatenpm:latest
194192
build_secrets:
@@ -201,7 +199,7 @@ Run a build with:
201199
faas-cli pro build -f stack.yml
202200
```
203201

204-
You'll also need an updated version of the node template to mount the secret passed in from the OpenFaaS Pro plugin. Update `template/node17/Dockerfile` and replace the second `npm i` command with:
202+
You'll also need an updated version of the node template to mount the secret passed in from the OpenFaaS Pro plugin. Update `template/node20/Dockerfile` and replace the second `npm i` command with:
205203

206204
```Dockerfile
207205
RUN --mount=type=secret,id=npmrc,mode=0666,dst=/home/app/.npmrc npm i

docs/cli/templates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ dockerfile [x] openfaas Classic Dockerfile templ
5656
dotnet8-csharp [x] openfaas C# template using WebApplication
5757
golang-middleware [x] openfaas HTTP middleware interface in Go
5858
java11-vert-x [x] openfaas Java 11 Vert.x template
59-
node18 [x] openfaas HTTP-based Node 18 template
59+
node20 [x] openfaas HTTP-based Node 18 template
6060
php8 [x] openfaas Classic PHP 8 template
6161
python3-http [x] openfaas Python 3 with Flask and HTTP
6262
python3-http-debian [x] openfaas Python 3 with Flask and HTTP based on Debian

docs/languages/custom.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This will include code submitted by a third party. It may or may not be kept up
3030

3131
### Make your own template
3232

33-
The easiest way to write a template for OpenFaaS it to copy an official template, and to modify it. This example creates a template using Bun and Express.js which is based upon the official node18 template.
33+
The easiest way to write a template for OpenFaaS it to copy an official template, and to modify it. This example creates a template using Bun and Express.js which is based upon the official node20 template.
3434

3535
Create a new folder called my-templates, it should have a sub-directory within it called `template`.
3636

@@ -57,7 +57,7 @@ Next, create a Dockerfile which should download and make available the OpenFaaS
5757
5858
There are two watchdogs available, the [Classic Watchdog](https://github.com/openfaas/classic-watchdog), meant for processes which do not have their own HTTP server, the process will be forked for each request, and the [of-watchdog](https://github.com/openfaas/of-watchdog) for when a HTTP server is available. Since Bun used with Express.js provides a HTTP server, we'll be using the of-watchdog.
5959
60-
The following Dockerfile is based upon the node18 template, adapted for Bun.
60+
The following Dockerfile is based upon the node20 template, adapted for Bun.
6161
6262
The `--platform=${TARGETPLATFORM:-linux/amd64}` directive is required for multi-arch support, to make the template work for 64-bit Arm as well as regular *x86_64* machines. Most images that you find on the Docker Hub will already have multi-arch support, and it's strongly recommended to keep it in place.
6363

docs/languages/node.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Create a new function using the template:
1616

1717
```bash
1818
faas-cli template pull
19-
faas-cli new --lang node18 echo
19+
faas-cli new --lang node20 echo
2020
```
2121

2222
You'll find a new folder called `echo` with a `handler.js` and `package.json` file inside.
@@ -64,7 +64,7 @@ Or to combine the `context.status()` method with the `context.succeed()` method
6464
To install packages, `cd` into the function folder and run `npm install --save`:
6565

6666
```bash
67-
faas-cli new --lang node18 http-req
67+
faas-cli new --lang node20 http-req
6868
cd http-req
6969

7070
npm install --save axios
@@ -128,12 +128,12 @@ Then create a new secret in OpenFaaS:
128128
faas-cli secret create node-fn-token --from-file node-fn-token.txt
129129
```
130130

131-
Create a new function using the *node18* template:
131+
Create a new function using the *node20* template:
132132

133133
```bash
134134
export OPENFAAS_PREFIX=ttl.sh/fns
135135

136-
faas-cli new --lang node18 node-fn
136+
faas-cli new --lang node20 node-fn
137137
```
138138

139139
Then edit the `node-fn/handler.js`:
@@ -172,7 +172,7 @@ Edit `node-fn.yml` and add the `secrets` section:
172172
```diff
173173
functions:
174174
node-fn:
175-
lang: node18
175+
lang: node20
176176
handler: ./node-fn
177177
image: ttl.sh/fns/node-fn:latest
178178
+ secrets:
@@ -206,7 +206,7 @@ When you test the function with `faas-cli up`, make sure you use the function's
206206

207207
Unit tests provide a quick and efficient way to exercise your code on your local computer, without needing to run `faas-cli build` or to deploy the function to a remote cluster.
208208

209-
With the node18 template, any unit tests that you provide will be run automatically upon each invocation of `faas-cli build`.
209+
With the node20 template, any unit tests that you provide will be run automatically upon each invocation of `faas-cli build`.
210210

211211

212212
By default, an empty test step is written to package.json inside your function's handler folder, you can override this with your own command or test runner.

docs/openfaas-pro/builder.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ Create a test function using the `python3` template, and set it to publish to `t
7474
```bash
7575
faas-cli new --prefix ttl.sh/test-images \
7676
--lang python3 py-fn
77-
mv py-fn.yml stack.yml
7877
```
7978

8079
Now, publish an image using the remote builder:
@@ -270,7 +269,7 @@ You may need to enable build arguments for the Dockerfile, these can be passed t
270269
{
271270
"image": "ttl.sh/alexellis/test-image:0.1.0",
272271
"buildArgs": {
273-
"BASE_IMAGE": "gcr.io/quiet-mechanic-140114/openfaas-base/node16"
272+
"BASE_IMAGE": "gcr.io/quiet-mechanic-140114/openfaas-base/node20"
274273
}
275274
}
276275
```

docs/openfaas-pro/kafka-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Most templates make these variables available through their request or context o
7777

7878
* [golang-middleware](/languages/go/)
7979
* [python3-http](/languages/python/)
80-
* [node17](/languages/node/)
80+
* [node20](/languages/node/)
8181

8282
For detailed examples with Node.js, see: [Serverless For Everyone Else](http://store.openfaas.com/l/serverless-for-everyone-else)
8383

docs/reference/private-registries.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ Create a sample function with a `--prefix` variable:
116116

117117
```sh
118118
faas-cli new --lang go private-fn --prefix=registry:port/repo
119-
mv private-fn.yml stack.yml
120119
```
121120

122121
Update the `stack.yml` file and add a reference to the new secret:

docs/reference/secrets.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ faas-cli template store pull python3-http
8383
export OPENFAAS_PREFIX=ttl.sh/alexellis
8484
8585
faas-cli new --lang python3-http protected-api
86-
mv protected-api.yml stack.yml
8786
```
8887

8988
Create a secret called `protected-api-token`, it will be used to authenticate all requests made to the new `protected-api` function.

docs/reference/yaml.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ functions:
4343
image: fn2:latest
4444
```
4545
46-
Then rename your file to stack.yml, so you don't need to specify the `-f` flag when using the CLI.
47-
48-
```bash
49-
mv fn1.yml stack.yml
50-
```
51-
5246
## Provider
5347
5448
The only valid value for provider `name` is `openfaas`.

0 commit comments

Comments
 (0)