Skip to content

Commit 68a3313

Browse files
authored
chore(docker): avoid running container as root
1 parent e4bf6cd commit 68a3313

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM python:3.13-slim AS builder
22
LABEL maintainer="Simone Locci <[email protected]>"
33

4+
RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser
5+
46
WORKDIR /build
57
RUN pip install --no-cache-dir poetry
68
COPY pyproject.toml poetry.lock ./
@@ -16,9 +18,12 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
1618
WORKDIR /app
1719
COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
1820
COPY --from=builder /usr/local/bin /usr/local/bin
21+
COPY --from=builder /etc/passwd /etc/passwd
22+
COPY --from=builder /etc/group /etc/group
1923
COPY app ./app
2024
COPY log_config.yml .
2125

2226
EXPOSE 8000
2327

28+
USER appuser
2429
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-config", "log_config.yml"]

0 commit comments

Comments
 (0)