-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdockerfile
37 lines (24 loc) · 990 Bytes
/
dockerfile
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
30
31
32
33
34
35
36
37
FROM python:3.12-bookworm AS build
ENV PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_NO_CACHE_DIR=off \
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy
WORKDIR /package
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
COPY pyproject.toml uv.lock ./
# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-editable --no-dev
COPY ./src ./src
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-editable --no-dev
FROM python:3.12-slim-bookworm AS app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/.venv/bin:$PATH"
RUN groupadd -r appuser && useradd -r -g appuser appuser
COPY --from=build /package/ ./
USER appuser
CMD ["python", "-m", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8080", "--proxy-headers", "--forwarded-allow-ips", "*"]