docker: run app as non-root user
This commit is contained in:
+7
-1
@@ -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"]
|
||||||
|
|||||||
Reference in New Issue
Block a user