# syntax=docker/dockerfile:1
# Agent Engine — embedding-pipeline-worker (document -> chunks -> embeddings)
# Build context: apps/workers/async/embedding-pipeline-worker
#
# No port and no HEALTHCHECK: this service serves nothing. It polls
# public.document_processing_jobs and is healthy when its process is alive.

# --- builder ----------------------------------------------------------------
FROM python:3.12-slim AS builder
WORKDIR /app
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_NO_CACHE_DIR=1
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY environment/requirements.txt ./requirements.txt
RUN pip install -U pip && pip install -r requirements.txt

# --- runtime ----------------------------------------------------------------
FROM python:3.12-slim AS runtime
WORKDIR /app
ENV PATH="/opt/venv/bin:$PATH" \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1

COPY --from=builder /opt/venv /opt/venv
COPY src ./src

RUN useradd --create-home --uid 10001 appuser && chown -R appuser:appuser /app
USER appuser

CMD ["python", "src/main.py"]
