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: README.rst
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -350,6 +350,60 @@ shows the different configuration options available:
350
350
# image is passed to subsequent steps.
351
351
import: path/to/image/archive.tar
352
352
353
+
# Specify the secrets that should be used when building your image,
354
+
# similar to the --secret option used by Docker
355
+
# More info about secrets: https://docs.docker.com/build/building/secrets/
356
+
secrets:
357
+
# Example of a secret that is a file
358
+
- id=secret1,src=<path to the secret file>
359
+
# Example of a secret that is an environment variable
360
+
- id=secret2,env=<environment variable name>
361
+
362
+
.. _Build Secrets:
363
+
364
+
Build Secrets
365
+
=============
366
+
367
+
Buildrunner supports specifying secrets that should be used when building your image,
368
+
similar to the --secret option used by Docker. This is done by adding the ``secrets``
369
+
section to the ``build`` section. This is a list of secrets that should be used when
370
+
building the image. The string should be in the format of ``id=secret1,src=<location of the file>``
371
+
when the secret is a file or ``id=secret2,env=<environment variable name>`` when the secret is an environment variable.
372
+
This syntax is the same as the syntax used by Docker to build with secrets.
373
+
More info about building with secrets in docker and the syntax of the secret string
374
+
see https://docs.docker.com/build/building/secrets/.
375
+
376
+
In order to use secrets in buildrunner, you need to do the following:
377
+
378
+
#. Update the buildrunner configuration file
379
+
* Set ``use-legacy-builder`` to ``false`` or add ``platforms`` to the ``build`` section
380
+
* Add the secrets to the ``secrets`` section in the ``build`` section
381
+
#. Update the Dockerfile to use the secrets
382
+
* Add the ``--mount`` at the beginning of each RUN command that needs the secret
383
+
384
+
.. code:: yaml
385
+
386
+
use-legacy-builder: false
387
+
steps:
388
+
build-my-container:
389
+
build:
390
+
dockerfile: |
391
+
FROM alpine:latest
392
+
# Using secrets inline
393
+
RUN --mount=type=secret,id=secret1 \
394
+
--mount=type=secret,id=secret2 \
395
+
echo Using secrets in my build - secret1 file located at /run/secrets/secret1 with contents $(cat /run/secrets/secret1) and secret2=$(cat /run/secrets/secret2)
396
+
# Using secrets in environment variables
397
+
RUN --mount=type=secret,id=secret1 \
398
+
--mount=type=secret,id=secret2 \
399
+
SECRET1_FILE=/run/secrets/secret1 \
400
+
SECRET2_VARIABLE=$(cat /run/secrets/secret2) \
401
+
&& echo Using secrets in my build - secret1 file located at $SECRET1_FILE with contents $(cat $SECRET1_FILE) and secret2=$SECRET2_VARIABLE
# More info about secrets: https://docs.docker.com/build/building/secrets/
6
+
use-legacy-builder: false
7
+
steps:
8
+
simple-build-step:
9
+
build:
10
+
no-cache: true
11
+
dockerfile: |
12
+
FROM alpine:latest
13
+
# Using secrets inline
14
+
RUN --mount=type=secret,id=secret1 \
15
+
--mount=type=secret,id=secret2 \
16
+
echo Using secrets in my build - secret1 file located at /run/secrets/secret1 with contents $(cat /run/secrets/secret1) and secret2=$(cat /run/secrets/secret2)
17
+
# Using secrets in environment variables
18
+
RUN --mount=type=secret,id=secret1 \
19
+
--mount=type=secret,id=secret2 \
20
+
SECRET1_FILE=/run/secrets/secret1 \
21
+
SECRET2_VARIABLE=$(cat /run/secrets/secret2) \
22
+
&& echo Using secrets in my build - secret1 file located at $SECRET1_FILE with contents $(cat $SECRET1_FILE) and secret2=$SECRET2_VARIABLE
# More info about secrets: https://docs.docker.com/build/building/secrets/
7
+
steps:
8
+
simple-build-step:
9
+
build:
10
+
dockerfile: |
11
+
FROM alpine:latest
12
+
# Using secrets inline
13
+
RUN --mount=type=secret,id=secret1 \
14
+
--mount=type=secret,id=secret2 \
15
+
echo Using secrets in my build - secret1 file located at /run/secrets/secret1 with contents $(cat /run/secrets/secret1) and secret2=$(cat /run/secrets/secret2)
16
+
# Using secrets in environment variables
17
+
RUN --mount=type=secret,id=secret1 \
18
+
--mount=type=secret,id=secret2 \
19
+
SECRET1_FILE=/run/secrets/secret1 \
20
+
SECRET2_VARIABLE=$(cat /run/secrets/secret2) \
21
+
&& echo Using secrets in my build - secret1 file located at $SECRET1_FILE with contents $(cat $SECRET1_FILE) and secret2=$SECRET2_VARIABLE
0 commit comments