2026-08-24 17:28:46 -04:00
|
|
|
FROM python:3.11-slim
|
|
|
|
|
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# libpq-dev + gcc for psycopg2 build/adapters; keep the image lean.
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
2026-08-28 22:53:31 -04:00
|
|
|
libpq-dev gcc tzdata \
|
2026-08-24 17:28:46 -04:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
COPY requirements.txt .
|
|
|
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
news: per-article proximate geolocation + GET /api/news/blips
Every graded article now carries best-effort geo on article_scores:
- parse_map_scores extracts Location/Lat/Lon/Confidence per block
(clamp_coords-validated; Unknown -> no geo; never invent a place)
- place-name-only blocks resolve via a vendored offline GeoNames
gazetteer (cities15000 + admin1 + country->capital), confidence approx
- nullable location_name/lat/lon/location_confidence columns (alembic
014, single head; idempotent ensure_tables mirror) + partial bbox index
- GET /api/news/blips: frozen contract, dedup by article id (latest geo
wins), finite coords only, created_at DESC, bbox/since/limit, default
1000 max 5000, public read like /api/news/map
- critical/high map pins, ticker, grading thresholds, dedupe unchanged
Tests: 50 new summarizer geo tests (161 total), 18 new blips API
contract tests; alembic upgrade heads proven on fresh DBs both start
orders; forced batch on test DB yielded 10 non-critical blips with geo.
Card: t_bc15eb53
2026-11-19 22:50:59 -05:00
|
|
|
COPY summarizer.py run_news_summarizer.py intel.py nous_client.py gazetteer.py ./
|
|
|
|
|
COPY data/ ./data/
|
2026-08-24 17:28:46 -04:00
|
|
|
|
|
|
|
|
# Security: run as a non-privileged user.
|
|
|
|
|
RUN useradd -m summarizer_user
|
|
|
|
|
USER summarizer_user
|
|
|
|
|
|
|
|
|
|
# Default: single pass (as the old k8s CronJob ran). The compose service
|
|
|
|
|
# overrides `command` to the scheduler loop (run_news_summarizer.py).
|
|
|
|
|
CMD ["python", "summarizer.py"]
|