feat(ebook): add Docker packaging and lifecycle tooling

Add a self-contained docker/ package for running the ebook search app
against the existing Postgres database on jeeves:

- Dockerfile: python:3.14-slim image, non-root user, runs the FastAPI
  app on port 8070
- docker-compose.yml: service definition with library volume mount,
  BM25 index volume, .env loading, and a /health healthcheck
- containers.py: Typer CLI (ebook-search-containers) for build/start/
  stop/restart/logs/ps lifecycle management
- README.md: usage and configuration docs
This commit is contained in:
2026-07-12 16:12:40 -04:00
parent f4c4b11ff8
commit f5ec88f1e5
5 changed files with 355 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
FROM python:3.14-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
APP_DIR=/home/richie/dotfiles \
EBOOK_SEARCH_HOST=0.0.0.0 \
EBOOK_SEARCH_PORT=8070 \
EBOOK_SEARCH_BM25_INDEX_DIR=/data/bm25
WORKDIR ${APP_DIR}
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential curl \
&& rm -rf /var/lib/apt/lists/*
COPY pyproject.toml README.md LICENSE ./
COPY python ./python
RUN python -m pip install --upgrade pip \
&& python -m pip install \
"alembic" \
"beautifulsoup4" \
"bm25s" \
"ebooklib" \
"fastapi" \
"httpx" \
"jinja2" \
"pgvector" \
"psycopg[binary]" \
"pydantic" \
"pydantic-settings" \
"python-multipart" \
"sqlalchemy" \
"tiktoken" \
"typer" \
"uvicorn[standard]" \
"yake" \
&& python -m pip install --no-deps --editable "${APP_DIR}"
RUN useradd --create-home --uid 10001 app \
&& mkdir -p /data \
&& chown -R app:app /home/richie /data
USER app
EXPOSE 8070
CMD ["sh", "-c", "exec python -m python.ebook_search.api.main --host \"${EBOOK_SEARCH_HOST}\" --port \"${EBOOK_SEARCH_PORT}\" --log-level \"${EBOOK_SEARCH_LOG_LEVEL:-INFO}\""]