Dockerfile•813 B
FROM python:3.12-slim
# Install uv from official image
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /app
# Install dependencies first for better cache behavior
COPY pyproject.toml /app/pyproject.toml
# If you have a uv.lock, uncomment the next line to improve reproducibility
# COPY uv.lock /app/uv.lock
# Sync only dependencies (project install skipped) for cache efficiency
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-install-project
# Copy the rest of the project
ADD . /app
# Sync project into the venv
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync
# Ensure venv is on PATH for uv run and entry points
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="/app/.venv/bin:$PATH"
# Run via uv (keeps parity with local: `uv run main.py`)
CMD ["uv", "run", "main.py"]