-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile.alpine
More file actions
29 lines (27 loc) · 1.08 KB
/
Copy pathDockerfile.alpine
File metadata and controls
29 lines (27 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# syntax=docker/dockerfile:1
FROM python:3.13-alpine@sha256:420cd0bf0f3998275875e02ecd5808168cf0843cbb4d3c536432f729247b2acc AS alpine
LABEL project="Python Insecure App" service="FastAPI" stage="alpine"
# RUN python3 -m pip install --upgrade pip~=26.1 \
# && apk upgrade --no-cache xz-libs
ENV NONROOT=nonroot \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
VIRTUAL_ENV=/opt/venv \
WORKDIR=/app
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
WORKDIR $WORKDIR
COPY --chown=$NONROOT ./requirements/base.txt requirements/base.txt
COPY --chown=$NONROOT ./requirements/common.txt requirements/common.txt
RUN addgroup -S $NONROOT \
&& adduser -S $NONROOT -G $NONROOT \
&& chown $NONROOT:$NONROOT $WORKDIR \
&& python3 -m venv $VIRTUAL_ENV \
&& chown -R $NONROOT:$NONROOT $VIRTUAL_ENV \
&& python3 -m pip install --no-cache-dir -r requirements/base.txt \
&& python3 -m uv pip install --no-cache --no-deps -r requirements/common.txt
USER $NONROOT
COPY --chown=$NONROOT app app
ENTRYPOINT [ "" ]
CMD [ "python3", "-m", "fastapi", "run", "app/main.py", "--port", "1337" ]