Skip to content

feat(repo): dockerize full stack (#275)#276

Merged
w7-mgfcode merged 4 commits into
devfrom
feat/repo-dockerize-full-stack
May 20, 2026
Merged

feat(repo): dockerize full stack (#275)#276
w7-mgfcode merged 4 commits into
devfrom
feat/repo-dockerize-full-stack

Conversation

@w7-mgfcode
Copy link
Copy Markdown
Owner

Summary

Implements PRP-32 — packages ForecastLabAI as a four-service Docker Compose stack so make docker-up brings 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-stage python:3.12-slim-bookworm + uv 0.11.8 (basedepsdevprod). Asyncpg-only path; no libpq.
  • Dockerfile.frontend — multi-stage Node 22 + pnpm via corepack (builderprod nginx:1.27-alpine → dev vite). 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 — adds backend, frontend, opt-in ollama services on a forecastlab bridge network; backend overrides DATABASE_URL → postgres:5432 and OLLAMA_BASE_URL → http://ollama:11434; frontend keeps VITE_* URLs on localhost:8123 (browser-is-consumer rule).
  • docker-compose.gpu.yml — Ollama NVIDIA passthrough override.
  • Makefiledocker-up, docker-up-gpu, docker-down targets.
  • DocsREADME.md quick-start subsection, docs/_base/RUNBOOKS.md H3 with 7 failure modes, docs/rag-ollama-setup.md in-cluster-vs-host URL paragraph (EN/HU).
  • Teststests/test_docker_stack.py: 3 integration tests gated on DOCKER_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 own chore(repo) commit).

Validation (executed locally before PR open)

  • L1docker compose config (base + gpu) clean; ruff check . + ruff format --check . clean.
  • L2mypy app/ 0 errors (276 files); pyright app/ 0 errors; pytest -m "not integration" 1430 passed.
  • L3make docker-up brought all 3 services Healthy in ~30 s; DOCKER_STACK_TEST=1 pytest -m integration tests/test_docker_stack.py 3/3 passed.
  • L4/health, /docs, SPA index, backend ↔ postgres:5432 via internal DNS all green; make docker-down clean teardown.
  • L5 (GPU) — skipped (host lacks nvidia-container-runtime, per PRP "SKIP on non-GPU CI").

Risk + rollback

  • Packaging-only change — no pyproject.toml / package.json dependency additions; no schema migrations; no API surface change.
  • Host-mode unchanged — existing docker compose up -d postgres + host-side uvicorn flow keeps working; the new services are additive.
  • Rollback — revert the 4 commits on this branch; nothing in dev is altered destructively.

Test plan

  • CI: Lint & Format, Type Check, Test, Migration Check all green.
  • Reviewer can run make docker-up and hit http://localhost:8123/health + http://localhost:5173/.
  • Reviewer can run make docker-down for clean teardown.

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.
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @w7-mgfcode, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec5d90bc-d2d3-4a59-85fe-9b728ffafcd8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/repo-dockerize-full-stack

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@w7-mgfcode w7-mgfcode merged commit 917a54c into dev May 20, 2026
8 checks passed
@w7-mgfcode w7-mgfcode deleted the feat/repo-dockerize-full-stack branch May 20, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant