Add FastAPI web/API layer and static site
- queries.py: shared read-only query helpers (feed, brief, category counts) returning plain dicts, used by the API and available to the CLI. - api.py: FastAPI service with Pydantic response models (the companion-app contract), CORS, and endpoints for categories, feed, brief, and health; mounts a static site at /. - static/index.html: minimal dependency-free site rendering the daily five and topic/flavor category browsing. - 'goodnews serve' command launches uvicorn (lazy import; core CLI stays pure-stdlib). Web deps live behind the optional [web] extra. - Dockerfile + .dockerignore + build-system metadata so the service installs and deploys cleanly, with the DB mounted as a shared volume. - README: web/API and deployment docs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
# goodNews web/API image.
|
||||
#
|
||||
# The SQLite database is NOT baked into the image — mount it at /data so the API
|
||||
# and the ingestion CLI (run separately, e.g. via cron on the host) share one
|
||||
# file. Build: docker build -t goodnews .
|
||||
# Run: docker run -p 8000:8000 -v /srv/goodnews/data:/data goodnews
|
||||
FROM python:3.13-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies first for better layer caching.
|
||||
COPY pyproject.toml README.md ./
|
||||
COPY goodnews ./goodnews
|
||||
RUN pip install --no-cache-dir ".[web]"
|
||||
|
||||
# API reads the database from here; mount a host dir or named volume.
|
||||
ENV GOODNEWS_DB=/data/goodnews.sqlite3
|
||||
VOLUME ["/data"]
|
||||
|
||||
EXPOSE 8000
|
||||
CMD ["uvicorn", "goodnews.api:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
Reference in New Issue
Block a user