FROM python:3.12-slim # Install uv (copy from the official image rather than curl) COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ # Set environment variables # - Activate the venv by putting it at the front of the PATH # - Compile bytecode for faster startup ENV PATH="/app/.venv/bin:$PATH" \ UV_COMPILE_BYTECODE=1 \ UV_LINK_MODE=copy WORKDIR /app # Install dependencies # Copy only the files needed to resolve dependencies first (better caching) COPY pyproject.toml uv.lock* ./ # Sync dependencies without installing the project itself yet RUN uv sync --frozen --no-install-project --no-dev # Copy source code and install the project COPY src /app/src RUN uv sync --frozen --no-dev # Runtime configuration ARG APP ENV APP=$APP ENV PYTHONPATH=$APP/src/:$PYTHONPATH ENV PYTHONUNBUFFERED=1 # Because PATH is updated, "python" now points to the venv python CMD ["python", "src/main.py"]