Skip to content

Commit de3b5bc

Browse files
weltekialexellis
authored andcommitted
Update docs: build secrets moved from pro-plugin to faas-cli
- Remove pro-plugin references from build secrets docs, use faas-cli build/publish directly - Update remote builder docs: build_secrets values are now file paths, not literal values - Add build_secrets section to YAML reference Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
1 parent e1289e2 commit de3b5bc

File tree

4 files changed

+35
-53
lines changed

4 files changed

+35
-53
lines changed

docs/cli/build.md

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,21 @@ When it comes to continuous integration and delivery you can use the `faas-cli`
2020

2121
If you are using an alternative container image builder or are automating the `faas-cli` then you can use the `--shrinkwrap` flag which will produce a folder named `./build/function-name` with a Dockerfile. This bundle can be used with any container builder.
2222

23-
## Plugins and build-time secrets
23+
## Build-time secrets
2424

25-
!!! info "Experimental feature"
26-
27-
This is an experimental feature which means that it may change in the future.
28-
29-
When using Docker's buildkit project to build your containers, faas-cli can pass in the arguments to mount different secrets into the build process.
30-
31-
Any other mechanism should be considered insecure because it will leak into the final image or the local image in one way or another.
25+
When using Docker's BuildKit to build your containers, `faas-cli` can mount secrets into the build process using Docker's `--secret` flag. This prevents sensitive values from leaking into the final image, which can happen when using `--build-arg`.
3226

3327
For Go users, make use of vendoring. It's what we use and it means you do not have to resort to insecure practices like sharing Personal Access Tokens (PAT) between users.
3428

3529
Below we have an example for Python using the pip package manager and for node modules with npm. The approach is similar for different package managers.
3630

37-
1. Download and enable the OpenFaaS Pro plugin
38-
2. Create a local file in the format required
39-
3. Update a `build_secret` in `stack.yml` so it gets mounted into the container
40-
4. Run `faas-cli pro build` or `faas-cli pro publish`, `faas-cli pro up` is not available at this time
31+
1. Create a local file containing the secret value
32+
2. Add a `build_secrets` entry in `stack.yml` pointing to the file path
33+
3. Use `RUN --mount=type=secret` in the Dockerfile to access the secret at build time
34+
4. Run `faas-cli build` or `faas-cli publish`
4135

4236
### Private access to a Python pip repository
4337

44-
First enable OpenFaaS Pro:
45-
46-
```bash
47-
faas-cli plugin get pro
48-
faas-cli pro enable
49-
```
50-
5138
Download the OpenFaaS Pro template using your customer credentials:
5239

5340
```bash
@@ -93,29 +80,10 @@ index-url = https://aws:CODEARTIFACT_TOKEN@OWNER-DOMAIN.d.codeartifact.us-east-1
9380
Then run a build with:
9481

9582
```bash
96-
faas-cli pro build
83+
faas-cli build
9784
```
9885

99-
The `faas-cli pro publish` command can also be used instead of `faas-cli pro build`.
100-
101-
Within a GitHub Action, the short-lived token associated to the job is used to verify your license for this feature.
102-
103-
Add to your workflow.yaml:
104-
105-
```yaml
106-
permissions:
107-
contents: 'read'
108-
id-token: 'write'
109-
```
110-
111-
Then:
112-
113-
```bash
114-
faas-cli plugin get pro
115-
faas-cli pro enable
116-
117-
faas-cli pro build / publish
118-
```
86+
The `faas-cli publish` command can also be used instead of `faas-cli build`.
11987

12088
If you're cloning from a private Git repository, without using a private PyPi repository, then you can use the `.netrc` approach instead:
12189

@@ -141,13 +109,6 @@ Bear in mind that at this time, `GITHUB_TOKEN` in a GitHub Action cannot be used
141109

142110
### Private npm modules
143111

144-
Get the OpenFaaS Pro plugin and enable it:
145-
146-
```bash
147-
faas-cli plugin get pro
148-
faas-cli pro enable
149-
```
150-
151112
Create a function:
152113

153114
```bash
@@ -196,10 +157,10 @@ functions:
196157
Run a build with:
197158

198159
```bash
199-
faas-cli pro build -f stack.yml
160+
faas-cli build -f stack.yml
200161
```
201162

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/node22/Dockerfile` and replace the second `npm i` command with:
163+
Update `template/node22/Dockerfile` and replace the second `npm i` command to mount the secret:
203164

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

docs/languages/php.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ That way you can pass in tokens for Composer, if necessary, GitHub tokens to get
7272

7373
Bear in mind that any tokens used with `--build-arg` will be made available in the final container image.
7474

75-
[OpenFaaS Standard's](https://openfaas.com/pricing) `faas-cli pro build` has a specific way to handle this without leaking secrets into the final image.
75+
Use [build secrets](/cli/build/#build-time-secrets) with `faas-cli build` to handle this without leaking secrets into the final image.
7676

7777
### PHP Extensions
7878

docs/openfaas-pro/builder.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Distribute the `key.pub` file to anyone who needs to build with secrets.
133133

134134
#### Using build secrets with `faas-cli`
135135

136-
Add `build_secrets` to your `stack.yaml`:
136+
Add `build_secrets` to your `stack.yaml`. The values must be file paths — `faas-cli` reads the file contents before sealing and sending them to the builder:
137137

138138
```yaml
139139
functions:
@@ -142,10 +142,13 @@ functions:
142142
handler: ./my-function
143143
image: registry.example.com/my-function:latest
144144
build_secrets:
145-
pip_token: my-secret-token
146-
registry_url: https://token:secret@registry.example.com/simple
145+
pip_token: .secrets/pip_token.txt
146+
registry_url: .secrets/registry_url.txt
147147
```
148148
149+
!!! warning "Do not store secrets in handler folders"
150+
We recommend storing build secret files in a `.secrets/` folder alongside your `stack.yaml`. Never place secret files inside a function's handler folder — the handler contents are copied into the build context and will be included in the resulting container image, leaking your secrets.
151+
149152
Use `--mount=type=secret` in your Dockerfile to access them:
150153

151154
```Dockerfile

docs/reference/yaml.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,24 @@ functions:
152152

153153
These can also be passed via the CLI using `faas-cli build --build-arg key=value` or `faas-cli up --build-arg key=value`
154154

155+
### Function: Build Secrets (`build_secrets`)
156+
157+
A map of build secrets can be used to mount sensitive values into the build process using Docker's `RUN --mount=type=secret` instruction. Unlike `build_args`, build secrets are not leaked into the final image.
158+
159+
Each value is a file path. The `faas-cli` reads the file contents and passes them to Docker via `--secret id=<key>,src=<path>`.
160+
161+
```yaml
162+
functions:
163+
my-function:
164+
handler: ./my-function
165+
lang: python3-http
166+
build_secrets:
167+
pipconf: ${HOME}/.config/pip/pip.conf
168+
netrc: ${HOME}/.netrc
169+
```
170+
171+
See [Build-time secrets](/cli/build/#build-time-secrets) for detailed examples.
172+
155173
### Function: Environmental variables
156174

157175
You can set configuration via environmental variables either in-line within the YAML file or in a separate external file. Do not store confidential or private data in environmental variables. See: secrets.

0 commit comments

Comments
 (0)