Skip to content

Commit a721034

Browse files
feat: add non-root user (#775)
1 parent 1170355 commit a721034

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/backend/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ FROM python:3.14-alpine
2727
# Python executable must be the same, e.g., using `python:3.11-slim-bookworm`
2828
# will fail.
2929

30-
# Copy the application from the builder
31-
COPY --from=builder --chown=app:app /app /app
30+
## Create a non-root user and group for running the application
31+
RUN addgroup -S chithi \
32+
&& adduser -S -G chithi -h /app -s /bin/sh chithi
33+
34+
# Copy the application from the builder and make it owned by the chithi user
35+
COPY --from=builder --chown=chithi:chithi /app /app
3236

3337
# Place executables in the environment at the front of the path
3438
ENV PATH="/app/.venv/bin:$PATH"
@@ -37,3 +41,7 @@ ENV HOST=127.0.0.1
3741
ENV PORT=8000
3842
EXPOSE 8000/udp 8000/tcp
3943

44+
# Use a non-root user
45+
WORKDIR /app
46+
USER chithi
47+

0 commit comments

Comments
 (0)