- Pyproject.toml mit FastAPI, Pydantic v2, SQLAlchemy, httpx, asyncio, BeautifulSoup4, selectolax, trafilatura, uvicorn, pytest-asyncio - Multi-stage Dockerfile (Python 3.12-slim, Non-Root-User nsct) - docker-compose.yml (nsct-api + postgres + optional searxng) - .env.example mit allen Config-Parametern - Config-System: AppSettings mit LLMConfig, VisionConfig, AudioConfig, DatabaseConfig — komplett aus Environment, keine Hardcodes - Strukturiertes Logging mit research_id/llm_request_id Tracking - Pydantic v2 Schemas: SearchQuery, Source, Claim, EvidenceRelation, CitationEdge, ResearchReport - SQLAlchemy 2.0 Declarative Models + async Engine Factory - SSRF-Schutz: URL-Validation, IP-Blocklist (RFC1918, Cloud Metadata, file://, ftp://) - Provider-Interfaces: LLMProvider, VisionProvider, AudioProvider, SearchProvider, ContentFetcher als ABCs - Health-Endpoints: /health, /ready (LLM-Connect-Test), /providers - FastAPI App mit CORS, lifespan (LLM Pre-Flight) - CLI-Stub mit Entry-Points: nsct, nsct-core, nsct-api - 6 Test-Cases: /health, /ready, /providers + No-Secrets-Test - Vollständige Dokumentation: README, ARCHITECTURE, SECURITY, METHODOLOGY, API, DEPLOYMENT - .gitignore (Python, Docker, IDE, .env)
49 lines
1.2 KiB
Docker
49 lines
1.2 KiB
Docker
# ============================================================
|
|
# NSCT — Neutral Search Crawler Tool
|
|
# Multi-stage Docker build, non-root user
|
|
# ============================================================
|
|
|
|
# ---------- Build stage ----------
|
|
FROM python:3.12-slim AS builder
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
PIP_DEFAULT_TIMEOUT=60
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /build
|
|
|
|
COPY pyproject.toml ./
|
|
RUN pip install --prefix=/install uvicorn fastapi pydantic pydantic-settings \
|
|
httpx sqlalchemy asyncpg beautifulsoup4 selectolax trafilatura structlog
|
|
|
|
COPY src/ ./src/
|
|
|
|
# ---------- Runtime stage ----------
|
|
FROM python:3.12-slim AS runtime
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1
|
|
|
|
# Non-root user
|
|
RUN groupadd --gid 1000 nsct && \
|
|
useradd --uid 1000 --gid nsct --shell /bin/bash --create-home nsct
|
|
|
|
RUN mkdir -p /app/data && chown -R nsct:nsct /app/data
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /install /usr/local
|
|
COPY src/ ./src/
|
|
|
|
RUN chown -R nsct:nsct /app
|
|
|
|
USER nsct
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["uvicorn", "nsct.api.main:app", "--host", "0.0.0.0", "--port", "8080"] |