# Worker image for the streaming-validation orders example.
#
# Builds pycharter from source so the example tracks the local checkout
# rather than a published wheel.
FROM python:3.13-slim

WORKDIR /app

# Install pycharter with the streaming extras (Kafka client + Prometheus
# + aiohttp). Build context is the repo root, so the source layout is
# already in place.
COPY pyproject.toml setup.py README.md ./
COPY src/ ./src/

RUN pip install --no-cache-dir ".[kafka,streaming]"

# Ship the example contract + worker config alongside the binary.
COPY examples/streaming/orders/contracts/ /app/contracts/
COPY examples/streaming/orders/stream-worker.yaml /app/stream-worker.yaml

# Run as a non-root user — even examples follow the production-image
# convention so reviewers can copy this Dockerfile straight into a real
# deployment without a security-review redo.
RUN useradd --create-home --shell /bin/bash --uid 10001 streaming \
    && chown -R streaming:streaming /app
USER streaming

CMD ["pycharter", "stream", "run", "/app/stream-worker.yaml"]
