Skip to content

Commit

Permalink
chore: Update Dockerfile to use non-root user for container execution
Browse files Browse the repository at this point in the history
  • Loading branch information
sahi-mfg committed May 12, 2024
1 parent fac25e7 commit 59dfa66
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ WORKDIR /app
# See https://docs.docker.com/go/dockerfile-user-best-practices/
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/user" \
--shell "/sbin/nologin" \
--uid "${UID}" \
appuser
--disabled-password \
--gecos "" \
--home "/user" \
--shell "/sbin/nologin" \
--uid "${UID}" \
appuser

# Copy the requirements.txt file into the container.
COPY requirements.txt .
Expand All @@ -34,10 +34,9 @@ COPY requirements.txt .
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
# Leverage a bind mount to requirements.txt to avoid having to copy them into
# into this layer.
RUN python -m pip install -r requirements.txt

USER root
RUN python -m pip install --no-cache-dir -r requirements.txt

USER appuser
# Copy the source code into the container.
COPY ./app ./app

Expand Down

0 comments on commit 59dfa66

Please sign in to comment.