FROM python:3.11-slim

WORKDIR /app

# Configure apt for rootless container compatibility and install curl for healthchecks
RUN apt-get -o APT::Sandbox::User=root update && \
    apt-get -o APT::Sandbox::User=root install -y --no-install-recommends curl && \
    rm -rf /var/lib/apt/lists/*

# Copy build manifests and source code
COPY pyproject.toml README.md ./
COPY src/ ./src/

# Install application and all production dependencies
RUN pip install --no-cache-dir .

EXPOSE 8000 8080

CMD ["knowledgeweaver", "serve", "--host", "0.0.0.0", "--port", "8000"]
