|
| 1 | +FROM python:3.11-slim-bookworm |
| 2 | + |
| 3 | +ENV PYTHONUNBUFFERED=1 |
| 4 | + |
| 5 | +WORKDIR /app/ |
| 6 | + |
| 7 | +# Install uv |
| 8 | +# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv |
| 9 | +COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /bin/ |
| 10 | + |
| 11 | +# Place executables in the environment at the front of the path |
| 12 | +# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment |
| 13 | +ENV PATH="/app/.venv/bin:$PATH" |
| 14 | + |
| 15 | +# Compile bytecode |
| 16 | +# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode |
| 17 | +ENV UV_COMPILE_BYTECODE=1 |
| 18 | + |
| 19 | +# uv Cache |
| 20 | +# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching |
| 21 | +ENV UV_LINK_MODE=copy |
| 22 | + |
| 23 | +# Install dependencies |
| 24 | +# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers |
| 25 | +#RUN --mount=type=cache,target=/root/.cache/uv \ |
| 26 | +# --mount=type=bind,source=uv.lock,target=uv.lock \ |
| 27 | +# --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ |
| 28 | +# uv sync --frozen --no-install-project |
| 29 | + |
| 30 | +ENV PYTHONPATH=/app |
| 31 | + |
| 32 | +# COPY ./scripts /app/scripts |
| 33 | + |
| 34 | + |
| 35 | +# COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/ |
| 36 | + |
| 37 | +# COPY ./alembic ./apps ./common /app/ |
| 38 | +COPY . /app/ |
| 39 | + |
| 40 | +# Sync the project |
| 41 | +# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers |
| 42 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 43 | + uv sync |
| 44 | + |
| 45 | +CMD ["fastapi", "run", "--workers", "4", "main.py"] |
| 46 | +# CMD ["uvicorn", "main:app", "--reload"] |
| 47 | +# CMD ["python", "main.py", "--reload"] |
0 commit comments