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
Copy file name to clipboardExpand all lines: docs/cli/build.md
+10-49Lines changed: 10 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,34 +20,21 @@ When it comes to continuous integration and delivery you can use the `faas-cli`
20
20
21
21
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.
22
22
23
-
## Plugins and build-time secrets
23
+
## Build-time secrets
24
24
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`.
32
26
33
27
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.
34
28
35
29
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.
36
30
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`
41
35
42
36
### Private access to a Python pip repository
43
37
44
-
First enable OpenFaaS Pro:
45
-
46
-
```bash
47
-
faas-cli plugin get pro
48
-
faas-cli pro enable
49
-
```
50
-
51
38
Download the OpenFaaS Pro template using your customer credentials:
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`.
119
87
120
88
If you're cloning from a private Git repository, without using a private PyPi repository, then you can use the `.netrc` approach instead:
121
89
@@ -141,13 +109,6 @@ Bear in mind that at this time, `GITHUB_TOKEN` in a GitHub Action cannot be used
141
109
142
110
### Private npm modules
143
111
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
-
151
112
Create a function:
152
113
153
114
```bash
@@ -196,10 +157,10 @@ functions:
196
157
Run a build with:
197
158
198
159
```bash
199
-
faas-cli pro build -f stack.yml
160
+
faas-cli build -f stack.yml
200
161
```
201
162
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:
203
164
204
165
```Dockerfile
205
166
RUN --mount=type=secret,id=npmrc,mode=0666,dst=/home/app/.npmrc npm i
Copy file name to clipboardExpand all lines: docs/languages/php.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ That way you can pass in tokens for Composer, if necessary, GitHub tokens to get
72
72
73
73
Bear in mind that any tokens used with `--build-arg` will be made available in the final container image.
74
74
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.
Copy file name to clipboardExpand all lines: docs/openfaas-pro/builder.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -133,7 +133,7 @@ Distribute the `key.pub` file to anyone who needs to build with secrets.
133
133
134
134
#### Using build secrets with `faas-cli`
135
135
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:
!!! 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
+
149
152
Use `--mount=type=secret` in your Dockerfile to access them:
Copy file name to clipboardExpand all lines: docs/reference/yaml.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -152,6 +152,24 @@ functions:
152
152
153
153
These can also be passed via the CLI using `faas-cli build --build-arg key=value` or `faas-cli up --build-arg key=value`
154
154
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
+
155
173
### Function: Environmental variables
156
174
157
175
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