FROM python:3.12-slim AS base

LABEL maintainer="MakeContextSimple Contributors"
LABEL description="Convert documents to semantic HTML optimized for LLM context"

# Set working directory
WORKDIR /app

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

# Copy dependency files first for better caching
COPY pyproject.toml README.md LICENSE ./

# Install Python dependencies
RUN pip install --no-cache-dir .[all]

# Copy source code
COPY src/ ./src/

# Install the package
RUN pip install --no-cache-dir -e .[all]

# Create non-root user for security
RUN useradd --create-home --shell /bin/bash appuser
USER appuser

# Default entrypoint
ENTRYPOINT ["makecontextsimple"]
CMD ["--help"]

# --- Production stage ---
FROM base AS production

# Copy sample files for testing
COPY GLOBALDEPOSITORY.pdf /data/

# Set volume for input/output
VOLUME ["/data"]

# Default to showing help
CMD ["--help"]
