Files
baserow/docs/development/running-the-dev-env-with-docker.md
Davide Silvestri 0bb39e36c6 [1/4] feat: AI assistant eval platform on self-hosted Phoenix (#5958)
* feat: add Phoenix LLM tracing service to the dev stack (ai profile)

* chore(deps): add openinference pydantic-ai instrumentation (dev)

* feat: export assistant traces to Phoenix when BASEROW_ASSISTANT_PHOENIX_URL is set

* fix: harden Phoenix tracing setup after review

* feat: Phoenix postgres storage, ai-evals profile and auth support

* docs: ADR 007 and assistant tracing/evals guides

* feat: assistant eval platform core (types, registries, scenarios)

* feat: eval harness with shared assistant factory

* feat: phoenix dataset sync for assistant evals

* feat: assistant eval experiments via phoenix client + CLI

* feat: migrate core, database and docs evals to the platform

Ports the 42 kuma-core/kuma-database/kuma-docs pytest evals into
declarative EvalCase/EvalScenario registrations, plus structure-level
tests asserting dataset counts, ids, and scenario wiring.

* feat: migrate builder and automation evals to the platform

Ports the 12 builder + 2 proactive + 2 user-source cases into
evals/datasets/builder.py (kuma-builder, 16 cases) and the 7 automation
cases into evals/datasets/automation.py (kuma-automation), following the
Task 5 pattern established in core.py/database.py. Extends
eval_platform/test_datasets.py with counts, id lists, a mode-per-case
assertion, and pre_state snapshot checks for the two cases that need one.

* fix: link traces and final counts for single-case eval runs

* fix: root spans for single-case eval runs use the assistant tracer provider

* feat: assistant eval runner service with run page

Adds the assistant_eval_runner management command (migrate -> instrumentation
-> dataset sync -> single worker thread -> wsgiref server) and its
runner.py module: a stdlib WSGI app serving a plain server-rendered page
(GET /, POST /run, GET /healthz) backed by a bounded in-memory run history
and one background worker draining a queue.Queue via run.run_experiment_for.

Wires the assistant-eval-runner compose service (ai-evals profile, own
baserow_evals DB), renames phoenix-db-init to ai-evals-db-init and extends
it to also create baserow_evals, and adds BASEROW_EVAL_RUNNER_PORT to both
env example files and the dev docs.

* fix: eval runner integration fixes

assistant-eval-runner needs its own SECRET_KEY/DATABASE_*/REDIS_* env vars:
dev-overlay compose services don't inherit docker-compose.yml's
x-backend-variables anchor (that's file-scoped YAML), so the container was
starting without a Django SECRET_KEY and without a Redis password, crashing
on auth. Also links to finished experiments pointed at the container-internal
BASEROW_ASSISTANT_PHOENIX_URL (http://phoenix:6006), unreachable from the
developer's browser.

Adds BASEROW_ASSISTANT_PHOENIX_PUBLIC_URL (defaulting to
http://localhost:${BASEROW_PHOENIX_PORT:-6060}) and has runner.py build the
Phoenix link from it, deep-linking straight to the finished run's experiment
compare view when its dataset_id/experiment_id are known, falling back to
the datasets list otherwise.

* refactor: retire the pytest eval harness

All 65 eval cases now live in baserow_enterprise.assistant.evals.datasets;
delete the legacy pytest-based suite and its `eval` markers.

* docs: rewrite assistant evals guide for the Phoenix platform

* feat: docs judge, prompt sync, git stamping and UI-contributed eval examples

- answer_quality LLM-as-judge evaluator for kuma-docs (BASEROW_EVAL_JUDGE_MODEL)
- Kuma prompts versioned into Phoenix on sync; experiments stamped with
  prompt hashes, git branch/commit and judge model
- sync preserves UI-added dataset examples with prompt-match adoption;
  eval-export emits paste-ready docs.py snippets
- final-review fixes: skip-safe scoring, runner CSRF/bind hardening,
  doc corrections

* feat: eval runner UI round — tabs, fan-out, reference answers, 64-case docs dataset

- Runner page: dataset tabs with selection badges, per-dataset and global
  all/none, cross-dataset fan-out (one experiment per dataset), 5s
  auto-refresh of runs, persistent run history across restarts, per-dataset
  Phoenix links, in-page Help tab rendering the repo docs via /docs.json.
- Reference answers for kuma-docs: EvalCase.reference_answer, judge grades
  against it, sync preserves UI-curated ones, eval-export round-trips them.
- kuma-docs grown to 64 cases: reference answers for all, PostHog-mined
  frequent questions, and cannot-do guardrail cases.
- Gemini (google:gemini-3.6-flash) in the eval model list.

* feat: runnable UI examples, prompt overrides, eval baseline and results view

- UI-added Phoenix examples now execute: docs questions get the standard
  docs checks + judge; tool cases declare scenario/expected_tools/
  answer_contains in metadata (empty-workspace default scenario). They are
  tickable per dataset on the runner page and run in whole-dataset
  experiments too.
- Prompt overrides: run any experiment with a prompt's latest Phoenix
  version instead of the code constant (runner checkbox panel with soft
  per-tab ordering, or --override-prompt). Agent singletons keep their
  dynamic instructions; effective hashes + override list stamped on the
  experiment.
- Committed baseline snapshot (evals/baseline.json, 111 cases) with
  just b eval-baseline capture/import; the runner imports it on startup so
  every Phoenix instance gets a baseline experiment per dataset,
  idempotent by content hash and run count.
- Results tab: all datasets in one view for a named experiment, with
  baseline deltas and a case-weighted overall row, via Phoenix experiment
  annotation summaries.
- New evaluation guide (docs/testing/ai-assistant-eval-analysis.md) served
  in the Help tab; layout uses horizontal space better (single tab row,
  fluid case columns).

* feat: time and cost in eval results, frozen into the baseline snapshot

- Results tab gains time (sum of run latencies) and cost/token columns per
  dataset and summed overall, with lower-is-better baseline deltas.
- eval-baseline capture freezes each dataset's time/cost/token totals into
  baseline.json; import stamps them as metadata so imported baselines
  (which carry no traces to price) still show time and cost.
- Importing a new baseline supersedes the previously imported one instead
  of accumulating duplicates.
- Changelog entry for the eval platform.

* fix: OpenInference attributes on subset-run task root spans

Bare wrapper spans rendered as kind 'unknown' with Unset status and empty
input/output in Phoenix. The Task root span now carries the CHAIN kind, the
case prompt as input, the run result as JSON output, and an explicit OK
status.

* polish; minor fixes

* fix: address eval platform review feedback

Apply production model settings and retries, isolate automation checks, and fix runner configuration, links, and result status.

Defer GPT-5.6 compatibility and baseline comparisons to #6034.

* fix: preserve model profiles in rebased eval harness

Use an explicit model profile for evals and share concrete models with tools. Manage model clients through the existing lifecycle helper and preserve regression coverage from the retired harness.

* fix: harden eval persistence and Phoenix access
2026-09-09 17:06:07 +02:00

323 lines
8.1 KiB
Markdown

# Running the Dev Environment with Docker
This guide covers running the Baserow development environment using Docker. This is the recommended approach for most developers as it requires minimal local setup and ensures a consistent environment.
## Prerequisites
### Required Tools
1. **Docker** - Install from https://docs.docker.com/desktop/ or similar alternatives. Allocate at least 4GB RAM (8GB recommended).
2. **Git** - Install from https://git-scm.com/downloads
3. **just** - Command runner
```bash
# macOS
brew install just
# Linux
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/.local/bin
```
See [supported.md](../installation/supported.md) for minimum version requirements.
### Verify Installation
```bash
docker -v
docker compose version
git --version
just --version
```
## Quick Start
```bash
# Clone the repository
git clone --branch develop https://github.com/baserow/baserow.git
cd baserow
# Build and start the dev environment
just dc-dev up -d
# View logs (Ctrl+C to stop following)
just dc-dev logs -f
```
Once started, access:
- **Frontend**: http://localhost:3000
- **Backend API**: http://localhost:8000
- **API Docs**: http://localhost:8000/api/redoc/
## How It Works
The Docker dev environment runs these services:
| Service | Description | Port |
|---------|-------------|------|
| `web-frontend` | Nuxt.js frontend with hot reload | 3000 |
| `backend` | Django API server with hot reload | 8000 |
| `celery` | Background task worker | - |
| `celery-export-worker` | Export-specific worker | - |
| `celery-beat-worker` | Scheduled task runner | - |
| `db` | PostgreSQL database | 5432 |
| `redis` | Redis cache and message broker | 6379 |
| `caddy` | Reverse proxy for media files | 4000 |
| `mailhog` | Email testing UI | 8025 |
| `mjml-email-compiler` | MJML to HTML email compiler | 28101 |
| `otel-collector` | OpenTelemetry OTLP/HTTP telemetry | 4318 |
| `volume-permissions-fixer` | Fixes media file permissions on startup | - |
| `web-frontend-storybook` | Component development UI | 6006 |
| `celery-flower` | Celery task monitoring | 5555 |
### Docker Compose Files
- `docker-compose.yml` - Base configuration (production-like)
- `docker-compose.dev.yml` - Development overrides (hot reload, volume mounts, dev settings)
The `just dc-dev` command combines both files automatically.
## Common Commands
Shortcuts: `dcd` = `dc-dev`, `a` = `dc-attach`, `dct` = `dc-dev tabs`
### Starting and Stopping
```bash
# Start all services (detached)
just dc-dev up -d # or: just dcd up -d
# Stop all services (preserves data)
just dc-dev stop
# Stop and remove containers (preserves volumes)
just dc-dev down
# Stop and remove everything including volumes (clean slate)
just dc-dev down -v
```
### Viewing Logs
```bash
# All logs
just dc-dev logs
# Follow logs in real-time
just dc-dev logs -f
# Specific services
just dc-dev logs backend
just dc-dev logs web-frontend
just dc-dev logs celery
# Last 100 lines of backend
just dc-dev logs -n 100 backend
```
### Running Commands in Containers
```bash
# Open a shell in a container
just a # Interactive container picker
just a backend # Direct shell into backend
just a celery # Interactive container picker, filtered
just dc-dev exec backend bash # Alternative
# Run Django management commands
just dc-dev exec backend python manage.py migrate
just dc-dev exec backend python manage.py createsuperuser
just dc-dev exec backend python manage.py shell_plus
# Run tests inside the container
just dc-dev exec backend just test
just dc-dev exec web-frontend yarn test
```
### Terminal Tabs and Tmux
```bash
# Open terminal tabs for each service (like the old dev.sh)
just dc-dev tabs # or: just dct
# Start a tmux session with all services
just dc-dev tmux
```
### Building Images
```bash
# Build all images
just dc-dev build --parallel
# Build specific service
just dc-dev build backend
# Build without cache (when things go wrong)
just dc-dev build --no-cache --parallel
# Clear Docker builder cache completely
# WARNING: This clears ALL Docker builder cache, not just Baserow!
just prune
```
### Restarting Services
```bash
# Restart a specific service
just dc-dev restart backend
# Rebuild and restart (after Dockerfile changes)
just dc-dev up -d --build backend
# Force recreate containers
just dc-dev up -d --force-recreate
```
## Optional Services
By default, all services including optional ones are started:
| Service | Description | Port |
|---------|-------------|------|
| `web-frontend-storybook` | Component development UI | 6006 |
| `celery-flower` | Celery task monitoring | 5555 |
| `phoenix` | LLM tracing & evals UI for the AI assistant (`ai-evals` profile) | 6060 |
| `assistant-eval-runner` | Web page to run the AI assistant evals (`ai-evals` profile) | 8090 |
This is controlled by the `COMPOSE_PROFILES` variable in `.env.docker-dev`. The `ai` profile starts what the AI assistant needs (`embeddings`); the `ai-evals` profile additionally starts `phoenix` — set `BASEROW_ASSISTANT_PHOENIX_URL=http://phoenix:6006` to export assistant traces (see [AI assistant tracing](./ai-assistant-tracing.md)).
```bash
# Default: start all services including optional ones
COMPOSE_PROFILES=optional
# To disable optional services (save resources), set to empty:
COMPOSE_PROFILES=
```
After changing this setting, restart the services:
```bash
just dc-dev down
just dc-dev up -d
```
## Hot Reloading
Both frontend and backend support hot reloading:
- **Frontend**: Changes to `.vue`, `.js`, `.scss` files trigger automatic browser refresh
- **Backend**: Changes to `.py` files trigger automatic server restart
You don't need to restart containers when editing code.
### When to Rebuild
You need to rebuild images when:
- `Dockerfile` changes
- `package.json` or `yarn.lock` changes (frontend)
- `pyproject.toml` or `uv.lock` changes (backend)
```bash
just dc-dev build --parallel
just dc-dev up -d
```
## Database Operations
### Running Migrations
```bash
just dc-dev exec backend python manage.py migrate
```
### Creating a Superuser
```bash
just dc-dev exec backend python manage.py createsuperuser
```
### Accessing the Database
```bash
# PostgreSQL shell
just dc-dev exec db psql -U baserow
# From backend container
just dc-dev exec backend python manage.py dbshell
```
### Resetting the Database
```bash
# Stop services, remove volumes, restart
just dc-dev down -v
just dc-dev up -d
```
## Environment Configuration
### Environment Files
The `just dc-dev` command uses `.env.docker-dev` to define the environment variables used by the `dev` containers.
This file is automatically created from `.env.docker-dev.example` if it doesn't exist.
### Customizing Settings
Look at [Configuration](../installation/configuration.md) to customize your `.env.docker-dev`.
### UID/GID for File Permissions
The dev containers run as your host user to avoid permission issues with mounted files:
```bash
# These are set automatically by just dc-dev
UID=$(id -u)
GID=$(id -g)
```
## Troubleshooting
### Container Won't Start
```bash
# Check container status
just dc-dev ps
# View logs for failing service
just dc-dev logs backend
# Rebuild from scratch
just dc-dev down -v
just prune
just dc-dev build --no-cache --parallel
just dc-dev up -d
```
### Slow Performance on macOS
Docker on macOS can be slow with volume mounts. Try:
1. Increase Docker Desktop resources (CPU, RAM)
2. Use Docker's VirtioFS file sharing (Docker Desktop settings)
3. Consider [local development](running-the-dev-env-locally.md) for faster iteration
### Database Connection Errors
```bash
# Ensure db is running and healthy
just dc-dev ps db
# Wait for database to be ready
just dc-dev exec db pg_isready -U baserow
# Check database logs
just dc-dev logs db
```
## Further Reading
- [justfile.md](justfile.md) - Complete command reference
- [running-tests.md](running-tests.md) - Running tests in Docker
- [running-the-dev-env-locally.md](running-the-dev-env-locally.md) - Alternative: local development
- [vscode-setup.md](vscode-setup.md) - VS Code configuration
- [intellij-setup.md](intellij-setup.md) - IntelliJ/PyCharm configuration