docker: run app as non-root user

This commit is contained in:
3252a8
2026-04-26 19:47:56 +03:00
parent 12376e5070
commit 250df445f0
+7 -1
View File
@@ -10,11 +10,17 @@ RUN --mount=type=cache,target=/root/.cache/pip \
FROM python:3.12-slim FROM python:3.12-slim
WORKDIR /app WORKDIR /app
RUN useradd -u 10001 -m appuser
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY . . COPY . .
RUN rm -rf /root/.cache RUN rm -rf /root/.cache
RUN mkdir -p /app/logs /app/data && chown -R appuser:appuser /app/logs /app/data
USER appuser
CMD ["python", "main.py"] CMD ["python", "main.py"]