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/*

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

# Copy service code
COPY services/template-service/pyproject.toml /app/
COPY services/template-service/src/ /app/src/
COPY services/template-service/alembic/ /app/alembic/
COPY services/template-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"]
