feat: unify on single repo-root compose file for dev and prod
Some checks failed
/ test (push) Has been cancelled
/ build (push) Has been cancelled
/ validate (push) Has been cancelled

This commit is contained in:
Jonas Miederer 2026-09-07 19:46:17 +00:00
parent 9acdbaa453
commit af993bd43f
18 changed files with 253 additions and 229 deletions

View file

@ -27,6 +27,10 @@ needs judgment. Every step is documented and traceable.
## Infrastructure
One `docker-compose.yml` at the repo root runs the whole stack — identical
services in dev and prod. Dev-only needs (editor, SSH keys, autoreload,
docker CLI) come from `.devcontainer/devcontainer.json`.
```mermaid
flowchart LR
subgraph Repo["Git repo — source of truth"]
@ -34,11 +38,11 @@ flowchart LR
end
subgraph Stack["Compose stack (dev + prod)"]
UI["frontend — React UI (3000)"]
API["app — FastAPI (8000)<br/>+ embedded flow-watcher"]
API["api — FastAPI (8000)<br/>+ embedded flow-watcher"]
DB[("app.db — SQLite file")]
LF["langflow — authoring UI (7860)<br/>langflow.db — SQLite file"]
LFX["lfx — flow runtime (6004)"]
WT["watchtower — nightly image updates"]
WT["watchtower — nightly image updates (prod)"]
end
UI --> API
FLOWS -->|watch + sync| API
@ -51,8 +55,8 @@ flowchart LR
| Service | Purpose | URL |
| -------------- | ------------------------------------ | -------------------------- |
| React frontend | Web UI (Vite) | http://localhost:3000 |
| FastAPI backend| API + flow orchestration | http://localhost:8000 |
| React frontend | Web UI (Vite, HMR in dev) | http://localhost:3000 |
| FastAPI backend| API + flow orchestration (reload in dev) | http://localhost:8000 |
| API docs | Swagger UI | http://localhost:8000/api/docs |
| Langflow | Visual flow authoring | http://localhost:7860 |
| LFX | Flow runtime (internal, no direct UI)| localhost:6004 |
@ -63,23 +67,22 @@ Langflow itself runs on SQLite by default — so the whole stack works without
a database server. Postgres can return later by changing `DATABASE_URL`
(migrations stay portable).
`.env` holds only ubiquitous variables (identical value in dev and prod:
secrets, service URLs). Dev-only variables travel via `devcontainer.json`
(`APP_ENV=dev`); paths resolve from the repo root in code.
## Getting Started
1. Copy `.env.example` to `.env` and fill in the secrets.
2. Open the repo in VS Code → "Reopen in Container". Setup installs
dependencies, migrates the database, and syncs `backend/flows/`.
3. Run the backend from `backend/`: `uv run uvicorn app.main:app --port 8000`.
Run the frontend from `frontend/`: `npm run dev`.
Production (self-hosted, internal use — no TLS/reverse proxy included):
```sh
docker compose -f compose.prod.yml up -d --build
```
dependencies and syncs `backend/flows/`; the entrypoints migrate and
serve automatically.
3. The stack is already running: UI at http://localhost:3000, API docs at
http://localhost:8000/api/docs.
## Development
Backend (from `backend/`):
Backend (attached `api` container, from `backend/`):
- `uv run pytest` — full test suite (throwaway SQLite file, no external DB).
- `uv run alembic upgrade head` — migrate the dev database.
@ -92,12 +95,33 @@ Backend (from `backend/`):
flows (writes test fixtures and `backend/flows/`).
- `uv run python scripts/smoke_e2e.py` — manual end-to-end smoke.
Frontend (from `frontend/`): `npm install`, `npm run dev`, `npm run build`.
Frontend (node lives in the `frontend` container):
- `docker compose exec frontend npm run dev` — HMR dev server (already
running via compose; this is for a second instance or flags).
- `docker compose exec frontend npm run build` — typecheck + build.
- Without a docker socket: VS Code "Attach to Running Container" → frontend.
Flow workflow: design in Langflow → export into `backend/flows/<name>.json`
(`--pull`, or UI download) → commit → the watcher deploys it automatically.
Deleting a file removes the flow including its runs (git keeps the JSON).
## Production (self-hosted, internal use — no TLS/reverse proxy included)
1. Check out the repo on the host, create `.env` from `.env.example` with
real secrets and `FRONTEND_MODE=preview`.
2. `docker compose up -d --build`.
3. Code updates via `git pull` + `docker compose restart api frontend`
(the checkout is bind-mounted); image rebuilds only for dependency
changes (`docker compose up -d --build`).
Container updates: registry images (`langflowai/langflow:latest`)
auto-update nightly via Watchtower (`nickfedor/watchtower`). Locally built
images (`app`, `lfx`, `frontend`) update with `docker compose build --pull`.
images (`api`, `lfx`, `frontend`) update with `docker compose build --pull`.
## Continuous integration
Workflows in `.forgejo/workflows/` run on Forgejo: backend pytest, frontend
build, compose validation. They need a Runner with the `docker` label online
(repo Settings → Actions → Runners) and action resolution for
`actions/checkout` (github proxy or `code.forgejo.org` mirror).