Skip to content

Commit 81bc86a

Browse files
committed
Update build/secrets examples
1 parent d3f21ed commit 81bc86a

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

README.rst

Lines changed: 0 additions & 7 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
@@ -401,12 +400,6 @@ In order to use secrets in buildrunner, you need to do the following:
401400
# Example of a secret that is an environment variable
402401
- id=secret2,env=SECRET2
403402
404-
405-
406-
407-
408-
409-
410403
.. _Running Containers:
411404

412405
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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
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

0 commit comments

Comments
 (0)