Skip to content

Commit af10760

Browse files
committed
non root dockerfile
1 parent b0d708f commit af10760

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
FROM python:3.12 as builder
2-
3-
WORKDIR /app
1+
FROM python:3.12 AS builder
42

3+
WORKDIR /builder
54
# python
65
ENV PYTHONUNBUFFERED=1 \
76
# prevents python creating .pyc files
@@ -17,6 +16,10 @@ RUN pip wheel --no-cache-dir --no-deps --wheel-dir ./wheels -r requirements.txt
1716

1817
FROM python:3.12-slim AS app
1918

19+
RUN adduser --system --group --home /home/nonroot nonroot
20+
ENV PATH="/home/nonroot/.local/bin:${PATH}"
21+
USER nonroot:nonroot
22+
2023
WORKDIR /app
2124

2225
# python
@@ -28,11 +31,10 @@ ENV PYTHONUNBUFFERED=1 \
2831
PIP_NO_CACHE_DIR=off \
2932
PIP_DISABLE_PIP_VERSION_CHECK=on
3033

31-
COPY --from=builder /app/wheels ./wheels
32-
COPY --from=builder /app/requirements.txt ./
34+
COPY --from=builder /builder/wheels ./wheels
35+
COPY --from=builder /builder/requirements.txt ./
3336

3437
RUN pip install --no-cache-dir ./wheels/*
35-
ENV PATH="/home/abc/.local/bin:${PATH}"
3638

3739
COPY ./src ./src
3840

0 commit comments

Comments
 (0)