FROM python:3.12-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    gcc libpq-dev && \
    rm -rf /var/lib/apt/lists/*

# Uncomment below if export-service needs headless browser / PDF rendering:
# --- Playwright (Chromium) ---
# RUN pip install playwright && playwright install --with-deps chromium
# --- WeasyPrint ---
# RUN apt-get update && apt-get install -y --no-install-recommends \
#     libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b libfribidi0 \
#     libgdk-pixbuf2.0-0 libcairo2 && \
#     rm -rf /var/lib/apt/lists/*

# Copy shared library
COPY shared/ /app/shared/

# Copy service code
COPY services/export-service/pyproject.toml /app/
COPY services/export-service/src/ /app/src/
COPY services/export-service/alembic/ /app/alembic/
COPY services/export-service/alembic.ini /app/alembic.ini

# Install dependencies
RUN pip install --no-cache-dir poetry && \
    poetry config virtualenvs.create false && \
    poetry install --no-interaction --no-ansi --no-root

# Set PYTHONPATH to include shared
ENV PYTHONPATH=/app:/app/src

EXPOSE 8000

CMD ["python", "-m", "src.infrastructure.main"]
