FROM python:3.12-slim AS base
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 PYTHONUNBUFFERED=1
WORKDIR /app
RUN pip install --no-cache-dir uv

FROM base AS production
COPY pyproject.toml ./
# Written to a file rather than piped: /bin/sh has no pipefail, so a failing bootstrap piped into
# uv would install nothing and still pass the build, leaving the app silently uninstrumented.
RUN uv pip install --system -e "." \
    && opentelemetry-bootstrap -a requirements > /tmp/otel-requirements.txt \
    && uv pip install --system -r /tmp/otel-requirements.txt
COPY . .
CMD ["bin/run-with-telemetry", "python", "-m", "app.job"]
