Skip to content

Commit 3509bab

Browse files
authored
Merge pull request openshift#7236 from bmcelvee/dedicated-3.6-stage
[dedicated-3.6] add a sample dockerfile for consuming input secrets
2 parents 711c2cd + e37559e commit 3509bab

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

dev_guide/builds/build_inputs.adoc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,28 @@ into that directory, relative to your *_Dockerfile_* location. This makes the
784784
secret files available to the Docker build operation as part of the context
785785
directory used during the build.
786786

787+
.Example of a Dockerfile referencing secret data
788+
====
789+
----
790+
FROM centos/ruby-22-centos7
791+
792+
USER root
793+
ADD ./secret-dir /secrets
794+
COPY ./secret2 /
795+
796+
# Create a shell script that will output secrets when the image is run
797+
RUN echo '#!/bin/sh' > /secret_report.sh
798+
RUN echo '(test -f /secrets/secret1 && echo -n "secret1=" && cat /secrets/secret1)' >> /secret_report.sh
799+
RUN echo '(test -f /secret2 && echo -n "relative-secret2=" && cat /secret2)' >> /secret_report.sh
800+
RUN chmod 755 /secret_report.sh
801+
802+
CMD ["/bin/sh", "-c", "/secret_report.sh"]
803+
----
804+
====
805+
787806
[NOTE]
788807
====
789-
Users should always remove their input secrets from the final application image
808+
Users should normally remove their input secrets from the final application image
790809
so that the secrets are not present in the container running from that image.
791810
However, the secrets will still exist in the image itself in the layer where
792811
they were added. This removal should be part of the *_Dockerfile_* itself.

0 commit comments

Comments
 (0)