feat(repo): dockerize full stack (#275)#276
Conversation
Multi-stage Dockerfile.backend (python:3.12-slim-bookworm + uv 0.11.8) with base/deps/dev/prod stages; asyncpg-only path so no libpq. Multi-stage Dockerfile.frontend (Node 22 + pnpm via corepack) with builder, prod (nginx:1.27-alpine SPA), and dev (vite --host 0.0.0.0) stages; PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=true works around pnpm 11 ERR_PNPM_IGNORED_BUILDS. .dockerignore excludes .venv, node_modules, docs/, examples/, PRPs/; keeps README.md (uv reads it via pyproject.toml.readme during uv sync).
docker-compose.yml: kept postgres block verbatim; added backend + frontend + opt-in ollama services, a forecastlab bridge network, and forecastlab_artifacts + forecastlab_ollama_models named volumes. Backend overrides DATABASE_URL to postgres:5432 (in-cluster DNS, NOT host localhost:5433) and OLLAMA_BASE_URL to http://ollama:11434. Frontend keeps VITE URLs on localhost:8123 (browser-is- consumer rule). Frontend healthcheck uses Node built-in fetch (no curl/wget needed in dev image). docker-compose.gpu.yml: Ollama NVIDIA passthrough override (deploy.resources.reservations.devices). Makefile: added .PHONY docker-up, docker-up-gpu, docker-down targets with help comments. .env.example + frontend/.env.example: fenced comment blocks documenting host- mode vs compose-mode for DATABASE_URL, OLLAMA_BASE_URL, VITE_API_BASE_URL, VITE_WS_URL. tests/test_docker_stack.py: 3 integration tests gated on DOCKER_STACK_TEST=1 (services_healthy, backend_can_reach_postgres_via_internal_dns, no_hardcoded_localhost_for_internal_services).
README.md: new "Run everything in containers" subsection + "GPU host (optional Ollama)" sub-subsection under Quick Start. docs/_base/RUNBOOKS.md: new H3 "Multi-container stack failed at step X" with 7 failure-mode resolutions (postgres race, port conflict, browser->backend hop, Loading regression, missing nvidia-container-runtime, slow start_period, migration failure). docs/rag-ollama-setup.md: bilingual EN/HU "Step 2.1: In-cluster URL vs host URL" paragraph clarifying compose-mode OLLAMA_BASE_URL. PRPs/INITIAL-docker-rev2.md + PRPs/PRP-32-dockerize-full-stack.md: source PRP artifacts that drove this work.
Incidental version-string bump from 0.2.16 to 0.2.17 picked up by uv sync during the docker work; matches .release-please-manifest.json. Split into its own commit so the dockerization diff stays a packaging-only change.
There was a problem hiding this comment.
Sorry @w7-mgfcode, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Implements PRP-32 — packages ForecastLabAI as a four-service Docker Compose stack so
make docker-upbrings the whole system (Postgres + backend + frontend + opt-in Ollama) up on any host that has Docker, with a separate GPU override for Ollama NVIDIA passthrough.Closes #275.
Changes
Dockerfile.backend— multi-stagepython:3.12-slim-bookworm+ uv 0.11.8 (base→deps→dev→prod). Asyncpg-only path; no libpq.Dockerfile.frontend— multi-stage Node 22 + pnpm via corepack (builder→prodnginx:1.27-alpine →devvite).PNPM_CONFIG_DANGEROUSLY_ALLOW_ALL_BUILDS=trueworks around pnpm 11ERR_PNPM_IGNORED_BUILDS..dockerignore— excludes.venv,node_modules,docs/,examples/,PRPs/. KeepsREADME.md(uv reads it viapyproject.toml.readmeduringuv sync).docker-compose.yml— addsbackend,frontend, opt-inollamaservices on aforecastlabbridge network; backend overridesDATABASE_URL → postgres:5432andOLLAMA_BASE_URL → http://ollama:11434; frontend keepsVITE_*URLs onlocalhost:8123(browser-is-consumer rule).docker-compose.gpu.yml— Ollama NVIDIA passthrough override.Makefile—docker-up,docker-up-gpu,docker-downtargets.README.mdquick-start subsection,docs/_base/RUNBOOKS.mdH3 with 7 failure modes,docs/rag-ollama-setup.mdin-cluster-vs-host URL paragraph (EN/HU).tests/test_docker_stack.py: 3 integration tests gated onDOCKER_STACK_TEST=1(services_healthy, backend↔postgres internal DNS, no-hardcoded-localhost static check).uv.lock— incidental 0.2.16 → 0.2.17 bump (split into its ownchore(repo)commit).Validation (executed locally before PR open)
docker compose config(base + gpu) clean;ruff check .+ruff format --check .clean.mypy app/0 errors (276 files);pyright app/0 errors;pytest -m "not integration"1430 passed.make docker-upbrought all 3 services Healthy in ~30 s;DOCKER_STACK_TEST=1 pytest -m integration tests/test_docker_stack.py3/3 passed./health,/docs, SPA index, backend ↔postgres:5432via internal DNS all green;make docker-downclean teardown.nvidia-container-runtime, per PRP "SKIP on non-GPU CI").Risk + rollback
pyproject.toml/package.jsondependency additions; no schema migrations; no API surface change.docker compose up -d postgres+ host-sideuvicornflow keeps working; the new services are additive.devis altered destructively.Test plan
make docker-upand hithttp://localhost:8123/health+http://localhost:5173/.make docker-downfor clean teardown.