Skip to content

Commit

Permalink
Fix: Made changes in the docker file such that the secret is injected…
Browse files Browse the repository at this point in the history
… in container properly
  • Loading branch information
Shubham-Patel07 committed Dec 30, 2024
1 parent ecea3e6 commit 8bebb50
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ RUN mkdir -p /app

# Use a separate RUN command for --mount
RUN --mount=type=secret,id=mysecret \
cat /run/secrets/mysecret > /app/secret.txt

export SECRET_VALUE=$(cat /run/secrets/mysecret) && \
echo $SECRET_VALUE >> /app/secret.txt

RUN adduser -u 2000 -D wrongsecrets
USER wrongsecrets
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile_webdesktop
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ RUN \
# Add secret handling for Kubernetes-specific Docker builds
# Create the /app directory to store the secret
RUN mkdir -p /app
# The secret will be written to a file for the challenge

# Use a separate RUN command for --mount
RUN --mount=type=secret,id=mysecret \
cat /run/secrets/mysecret > /var/tmp/wrongsecrets/secret.txt
export SECRET_VALUE=$(cat /run/secrets/mysecret) && \
echo $SECRET_VALUE >> /app/secret.txt

WORKDIR /config/Desktop

Expand Down
6 changes: 4 additions & 2 deletions Dockerfile_webdesktopk8s
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ RUN \
# Add a secret using --mount and write it to a specific file path for the challenge
# Create the /app directory to store the secret
RUN mkdir -p /app
# This demonstrates how secrets can be mishandled during Docker builds

# Use a separate RUN command for --mount
RUN --mount=type=secret,id=mysecret \
cat /run/secrets/mysecret > /var/tmp/wrongsecrets/secret.txt
export SECRET_VALUE=$(cat /run/secrets/mysecret) && \
echo $SECRET_VALUE >> /app/secret.txt

WORKDIR /config/Desktop

Expand Down

0 comments on commit 8bebb50

Please sign in to comment.