Skip to content

Commit 8ab3eac

Browse files
committed
Update build/secrets examples
1 parent d3f21ed commit 8ab3eac

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

README.rst

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ shows the different configuration options available:
359359
# Example of a secret that is an environment variable
360360
- id=secret2,env=<environment variable name>
361361
362-
363362
.. _Build Secrets:
364363

365364
Build Secrets
@@ -390,23 +389,22 @@ In order to use secrets in buildrunner, you need to do the following:
390389
build:
391390
dockerfile: |
392391
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
393397
RUN --mount=type=secret,id=secret1 \
394398
--mount=type=secret,id=secret2 \
395399
SECRET1_FILE=/run/secrets/secret1 \
396400
SECRET2_VARIABLE=$(cat /run/secrets/secret2) \
397-
echo "Using secrets in my build - secret1: $(cat $SECRET1_FILE) secret2: $SECRET2_VARIABLE"
401+
&& echo "Using secrets in my build - secret1 file located at $SECRET1_FILE with contents $(cat $SECRET1_FILE) and secret2=$SECRET2_VARIABLE"
398402
secrets:
399403
# Example of a secret that is a file
400404
- id=secret1,src=examples/build/secrets/secret1.txt
401405
# Example of a secret that is an environment variable
402406
- id=secret2,env=SECRET2
403407
404-
405-
406-
407-
408-
409-
410408
.. _Running Containers:
411409

412410
Running Containers (the ``run`` step attribute)

examples/build/secrets/buildrunner.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ use-legacy-builder: false
77
steps:
88
simple-build-step:
99
build:
10+
no-cache: true
1011
dockerfile: |
1112
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
1218
RUN --mount=type=secret,id=secret1 \
1319
--mount=type=secret,id=secret2 \
1420
SECRET1_FILE=/run/secrets/secret1 \
1521
SECRET2_VARIABLE=$(cat /run/secrets/secret2) \
16-
echo "Using secrets in my build - secret1: $(cat $SECRET1_FILE) secret2: $SECRET2_VARIABLE"
22+
&& echo "Using secrets in my build - secret1 file located at $SECRET1_FILE with contents $(cat $SECRET1_FILE) and secret2=$SECRET2_VARIABLE"
1723
secrets:
1824
# Example of a secret that is a file
1925
- id=secret1,src=examples/build/secrets/secret1.txt

examples/build/secrets/platforms-buildrunner.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@
22
# add platforms to the build section
33
# To run this example, you need to set the SECRET_PASSWORD environment variable
44
# and run the example with the following command:
5-
# SECRET2=my_secret ./run-buildrunner.sh -f examples/build/secrets/buildrunner-platforms.yaml
5+
# SECRET2=my_secret ./run-buildrunner.sh -f examples/build/secrets/platforms-buildrunner.yaml
66
# More info about secrets: https://docs.docker.com/build/building/secrets/
77
steps:
88
simple-build-step:
99
build:
1010
dockerfile: |
1111
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
1217
RUN --mount=type=secret,id=secret1 \
1318
--mount=type=secret,id=secret2 \
1419
SECRET1_FILE=/run/secrets/secret1 \
1520
SECRET2_VARIABLE=$(cat /run/secrets/secret2) \
16-
echo "Using secrets in my build - secret1: $(cat $SECRET1_FILE) secret2: $SECRET2_VARIABLE"
21+
&& echo "Using secrets in my build - secret1 file located at $SECRET1_FILE with contents $(cat $SECRET1_FILE) and secret2=$SECRET2_VARIABLE"
1722
secrets:
1823
# Example of a secret that is a file
1924
- id=secret1,src=examples/build/secrets/secret1.txt
2025
# Example of a secret that is an environment variable
2126
- id=secret2,env=SECRET2
2227
platforms:
2328
- linux/amd64
24-
- linux/arm64
29+
- linux/arm64/v8

0 commit comments

Comments
 (0)