Files
baserow/docker-compose.dev.yml
T
Davide Silvestri f5bc919473 feat(celery): make every task work on a threads worker, and use one in dev (#6926)
* chore(dev): run one threads Celery worker with beat in dev

The Docker and native dev stacks start a single Celery worker for every
queue, with redbeat embedded, instead of a worker, an export worker and a
beat process. It uses a new ThreadsPool that sends worker_process_init, so
telemetry and the lazy import check still run under the threads pool.

* fix(ws): stop closing every event loop's Redis pools after a broadcast

send_messages_to_channel_group called channel_layer.close_pools(), which
closes the pools of every event loop, including the ones other worker
threads are still sending with. Under the threads pool about a third of
broadcasts failed with "attached to a different loop" and some hung.
channels_redis now closes a loop's pools itself when that loop closes.

* fix(telemetry): keep Celery trace context per thread on threads workers

The Celery instrumentation keys a running task's span, context token and start
time by the task's id. A task replaced with self.replace(), like every
automation node, keeps its id, and on a threads worker the replacement can
start in another thread before the original ends. The original then ended the
replacement's span and detached its context from the wrong thread, logging
"Failed to detach context" and leaving its own context on the thread. That
state is now kept per thread.

* feat(celery): enforce soft and hard time limits in ThreadsPool

Celery's own threads pool ignores soft_time_limit and time_limit, so on a
threads worker tasks that rely on them would run on. ThreadsPool now raises
the limit in the task's thread, only while that task runs, so a limit never
reaches the next task of the thread. EMAIL_TIMEOUT stops a silent SMTP server
from blocking a worker thread forever.

* fix(chat-runs): cancel a run that keeps going after its deadline

The deadline only asks a run to stop. A run whose tools or provider call
ignore that request now gets 60 more seconds, is then cancelled, and is saved
as timed out. Celery's limit moves after that, so the run's own stop always
comes first. On a threads worker this is the only way to end it, because a
time limit can't reach a thread waiting inside async_to_sync.

* fix(premium): share one capped thread pool across AI field generations

Each generation started its own pool of
BASEROW_AI_FIELD_MAX_CONCURRENT_GENERATIONS threads, so a threads worker
running several jobs multiplied the threads and model calls. All generations
in a process now share one pool of that size. A prefork process runs one job
at a time, so nothing changes there.

* feat(celery): cancel queries at the hard limit and report overdue tasks

ThreadsPool checks every running task's time limits from one watchdog thread,
like the prefork pool's timeout handler, instead of starting timer threads
for each task. At the hard limit it also cancels the query the task's thread
is running, which the limit's exception can't interrupt.

A thread can't be killed, so a task still running 60 seconds after its hard
limit is reported to Sentry instead. Every limit reached is counted in
baserow.celery.task.time_limit, per task and limit.

* fix(airtable): time out requests to Airtable

Two Airtable import requests had no timeout, so a server that stopped
answering held the import, and on a threads worker its thread, forever. All
Airtable requests now use the same 3 minute read timeout.

* fix(celery): load sentry_sdk only when reporting an overdue task

The overdue report imported sentry_sdk at the top of baserow.config.celery,
which every process imports, so it was loaded even with Sentry off.

* chore: add a changelog entry for the Celery task timeouts

* fix(celery): raise threads pool time limits at the task's next query

An exception raised into a thread from outside can land right after a lock
is taken and before the code that releases it, leaving the lock held for
every thread of the worker. The pool now marks a reached limit and the
task's own next query raises it, once, through a connection execute
wrapper. The hard limit still cancels the running query, and raises
TimeLimitExceeded whatever the soft limit is. Limits end before Celery's
success callback runs. Savepoint queries are never interrupted, through
a helper shared with the periodic field update deadline.

* fix(celery): apply the worker default time limits on the threads pool

Celery passes CELERY_TASK_SOFT_TIME_LIMIT and CELERY_TASK_TIME_LIMIT to the pool and None per task when a task sets no limit. The prefork pool falls back to the pool's values; the threads pool now does too.

* fix(celery): keep threads pool time limits until running tasks end

The watchdog stopped before on_stop waited for the running tasks, so a task passing its limit during a warm shutdown was never stopped or reported.

* chore: name the emails the SMTP timeout covers in the changelog

EMAIL_TIMEOUT applies to the instance's own emails only. Automation and builder SMTP steps already time out after 30 seconds.

* chore(dev): drop dev.sh tabs for the removed Celery workers

The export and beat services are disabled, so attaching to them made the script exit before opening the remaining tabs.

* test(celery): cover thread time limits and savepoint rollback

* fix(ai): use one generation slot for nonpositive limits

* fix(chat): warn that an action may finish after a reply times out

* docs(celery): explain which timeout guarantees require prefork

* docs(celery): record the threads pool decision and task contract

* fix(chat): keep the worker slot until started tools finish

* fix(chat): warn visitors about repeating a timed-out request

* docs(chat): clarify when the stop grace period begins
2026-12-03 09:39:52 +01:00

428 lines
16 KiB
YAML

services:
db:
# use lowest supported version for dev to check compatibility
image: pgvector/pgvector:pg${POSTGRES_IMAGE_VERSION:-14}
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_POSTGRES_PORT:-5432}:5432"
command: "${POSTGRES_DEV_EXTRA_ARGS}"
volumes:
# Use a different volume in case the Major version is different from the
# production one to avoid issues.
- pgdatadev:/var/lib/postgresql/data
redis:
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_DEBUG_REDIS_PORT:-6379}:6379"
# Override with the dev caddy file which switches Caddy to only be the media file
# server in the dev env. Devs will instead directly connect to the backend and
# web frontend services.
caddy:
volumes:
- $PWD/Caddyfile.dev:/etc/caddy/Caddyfile
backend:
image: baserow_backend:dev
environment:
- OAUTHLIB_INSECURE_TRANSPORT
- BASEROW_BACKEND_DEBUGGER_ENABLED
- BASEROW_DEV_POPULATE_OPENAI_API_KEY_FILE
- BASEROW_DEV_POPULATE_ANTHROPIC_API_KEY_FILE
- BASEROW_BACKEND_DEBUGGER_PORT=${BASEROW_BACKEND_DEBUGGER_PORT:-5678}
- BASEROW_DANGEROUS_SILKY_ANALYZE_QUERIES
- BASEROW_ENABLE_SILK
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
- OTEL_TRACES_SAMPLER=always_on
- BASEROW_EMBEDDINGS_API_URL=${BASEROW_EMBEDDINGS_API_URL}
- BASEROW_ASSISTANT_PHOENIX_URL=${BASEROW_ASSISTANT_PHOENIX_URL:-}
- BASEROW_ASSISTANT_PHOENIX_API_KEY=${BASEROW_ASSISTANT_PHOENIX_API_KEY:-}
build:
dockerfile: ./backend/Dockerfile
context: .
target: dev
args:
# We allow configuring the UID/GID here so you can run as the dev's actual user
# reducing the chance the containers screw up the bind mounted folders.
UID: $UID
GID: $GID
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_BACKEND_HOST_PORT:-8000}:8000"
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_BACKEND_DEBUGGER_PORT:-5678}:${BASEROW_BACKEND_DEBUGGER_PORT:-5678}"
volumes:
- ./docs:/baserow/docs
- ./backend:/baserow/backend
- ./premium/backend/:/baserow/premium/backend
- ./enterprise/backend/:/baserow/enterprise/backend
- ./deploy/plugins/:/baserow/plugins/
- ./tests:/baserow/tests
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
depends_on:
- otel-collector
web-frontend:
image: baserow_web-frontend:dev
build:
dockerfile: ./web-frontend/Dockerfile
context: .
target: dev
args:
# We allow configuring the UID/GID here so you can run as the dev's actual user
# reducing the chance the containers screw up the bind mounted folders.
UID: $UID
GID: $GID
command: "nuxt-dev"
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_WEB_FRONTEND_DEV_PORT:-3000}:3000"
volumes:
- ./web-frontend:/baserow/web-frontend
- ./premium/web-frontend/:/baserow/premium/web-frontend
- ./enterprise/web-frontend/:/baserow/enterprise/web-frontend
- ./tests/:/baserow/tests
- ./deploy/plugins:/baserow/plugins
# dev volumes to avoid polluting your local filesystem with build files or
# overwriting existing node_modules.
- node_modules:/baserow/web-frontend/node_modules
- nuxt:/baserow/web-frontend/.nuxt/
- cache:/baserow/web-frontend/.cache/
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
storybook:
image: baserow_web-frontend:dev
profiles: ["optional"]
build:
dockerfile: ./web-frontend/Dockerfile
context: .
target: dev
args:
# We allow configuring the UID/GID here so you can run as the dev's actual user
# reducing the chance the containers screw up the bind mounted folders.
UID: $UID
GID: $GID
command: "storybook-dev"
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_STORYBOOK_PORT:-6006}:6006"
volumes:
- ./web-frontend:/baserow/web-frontend
- ./premium/web-frontend/:/baserow/premium/web-frontend
- ./enterprise/web-frontend/:/baserow/enterprise/web-frontend
- ./tests/:/baserow/tests
- ./deploy/plugins:/baserow/plugins
# dev volumes to avoid polluting your local filesystem with build files or
# overwriting existing node_modules.
- node_modules:/baserow/web-frontend/node_modules
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://localhost:6006/"]
interval: 60s
timeout: 5s
retries: 3
start_period: 30s
celery:
image: baserow_backend:dev
user: "${UID}:${GID}"
command: "watch-py celery-worker -Q celery,export,automation_workflow,chat_run -P custom -c 25 -B --scheduler redbeat.RedBeatScheduler"
environment:
- CELERY_CUSTOM_WORKER_POOL=baserow.config.celery:ThreadsPool
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
- OTEL_TRACES_SAMPLER=always_on
- BASEROW_DANGEROUS_SILKY_ANALYZE_QUERIES
- BASEROW_ASSISTANT_PHOENIX_URL=${BASEROW_ASSISTANT_PHOENIX_URL:-}
- BASEROW_ASSISTANT_PHOENIX_API_KEY=${BASEROW_ASSISTANT_PHOENIX_API_KEY:-}
volumes:
- ./docs:/baserow/docs
- ./backend:/baserow/backend
- ./premium/backend/:/baserow/premium/backend
- ./enterprise/backend/:/baserow/enterprise/backend
- ./deploy/plugins:/baserow/plugins
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
depends_on:
- otel-collector
# The celery service runs every queue and beat in dev.
celery-export-worker:
profiles: ["disabled"]
celery-beat-worker:
profiles: ["disabled"]
celery-flower:
image: baserow_backend:dev
user: "${UID}:${GID}"
profiles: ["optional"]
restart: unless-stopped
stop_signal: SIGQUIT
command: "celery-flower"
healthcheck:
test: ["CMD-SHELL", "curl --fail http://localhost:5555 || exit 1"]
interval: 30s
timeout: 10s
retries: 3
environment:
REDIS_HOST:
REDIS_PORT:
REDIS_PROTOCOL:
REDIS_URL:
REDIS_SSL_CERT_REQS:
REDIS_SSL_CA_CERTS:
REDIS_USER:
REDIS_PASSWORD: ${REDIS_PASSWORD:?}
volumes:
- ./backend:/baserow/backend
- ./premium/backend/:/baserow/premium/backend
- ./enterprise/backend/:/baserow/enterprise/backend
- ./deploy/plugins:/baserow/plugins
- media:/baserow/media
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_CELERY_FLOWER_PORT:-5555}:5555" # web ui
networks:
local:
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
mjml-email-compiler:
image: baserow_web-frontend:dev
depends_on:
- web-frontend
user: "${UID}:${GID}"
command: "bash -c 'cd /baserow/backend/email_compiler/ && yarn install && yarn run watch'"
healthcheck:
disable: true
volumes:
- ./backend:/baserow/backend
- ./web-frontend/docker:/baserow/web-frontend/docker
- ./deploy/plugins:/baserow/plugins
# Open stdin and tty so when attaching key input works as expected.
stdin_open: true
tty: true
# Inbound email receiver (mox) for the "Start workflow by email" automation
# trigger. Opt-in via the base file's "inbound-email" profile: `just mox up`
# starts it next to a natively running backend, and
# `COMPOSE_PROFILES=optional,inbound-email` starts it as part of
# `just dc-dev up`. Same `email-receiver` role as production, but built from
# the dev image so no Go toolchain or `brew install mox` is needed.
email-receiver:
image: baserow_backend:dev
# Inherited from the base file, repeated here so it is not mistaken for an
# omission: the receiver only exists under this profile.
profiles: ["inbound-email"]
build:
dockerfile: ./backend/Dockerfile
context: .
target: dev
args:
UID: $UID
GID: $GID
# The SMTP port mapping comes from the base file and is env-driven:
# .env.docker-dev publishes it on 127.0.0.1:2025 (off port 25, like mailhog).
# The web API is published on loopback too so a natively running backend
# (`just dev`) can delete handed-over messages through it.
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_INBOUND_EMAIL_WEBAPI_HOST_PORT:-8880}:${BASEROW_INBOUND_EMAIL_WEBAPI_PORT:-8880}"
# Lets the container reach a backend running natively on the host.
extra_hosts:
- "host.docker.internal:host-gateway"
# The dev image expects the source and plugin helpers bind-mounted, like
# the backend service above.
volumes:
- ./backend:/baserow/backend
- ./deploy/plugins/:/baserow/plugins/
mailhog:
image: mailhog/mailhog
logging:
driver: "none" # disable saving logs
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_MAILHOG_SMTP_PORT:-1025}:1025" # smtp
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_MAILHOG_WEB_PORT:-8025}:8025" # web ui
networks:
local:
keycloak:
image: quay.io/keycloak/keycloak:26.7
profiles: ["authentication"]
command: ["start-dev", "--import-realm"]
environment:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: admin
# Browser-facing URLs use localhost, while backchannel URLs are resolved from
# the request so backend containers can communicate with http://keycloak:8080.
KC_HOSTNAME: http://localhost:${BASEROW_KEYCLOAK_PORT:-8081}
KC_HOSTNAME_BACKCHANNEL_DYNAMIC: "true"
PUBLIC_BACKEND_URL: ${PUBLIC_BACKEND_URL:-http://localhost:8000}
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_KEYCLOAK_PORT:-8081}:8080"
volumes:
- ./deploy/keycloak/baserow-dev-realm.json:/opt/keycloak/data/import/baserow-dev-realm.json:ro
networks:
local:
# Dotted alias so a Docker-internal backend can reach Keycloak with a URL
# the frontend OIDC form accepts (its `url` validator rejects dotless
# hostnames like `keycloak` and private IPs). See docs/development/builder-authentication.md.
aliases:
- keycloak.internal
# When switching between dev and local the media files in the media volume will be
# owned by different users. Ensure that we chown them to the user appropriate for the
# environment here.
volume-permissions-fixer:
image: bash:4.4
command: chown ${UID:-9999}:${GID:-9999} -R /baserow/media
volumes:
- media:/baserow/media
- caddy_config:/config
- caddy_data:/data
networks:
local:
otel-collector:
image: otel/opentelemetry-collector-contrib:0.161.0
command:
- "--config=/etc/otel-collector-config.yaml"
- "--feature-gates=processor.tailsamplingprocessor.recordpolicy"
environment:
HONEYCOMB_API_KEY:
HONEYCOMB_METRICS_DATASET: baserow-dev-metrics
BASEROW_OTEL_TAIL_SAMPLING_DECISION_WAIT: ${BASEROW_OTEL_TAIL_SAMPLING_DECISION_WAIT:-5m}
BASEROW_OTEL_TAIL_SAMPLING_DECISION_WAIT_AFTER_ROOT_RECEIVED: ${BASEROW_OTEL_TAIL_SAMPLING_DECISION_WAIT_AFTER_ROOT_RECEIVED:-5s}
BASEROW_OTEL_TAIL_SAMPLING_MAX_SPANS_PER_SECOND: ${BASEROW_OTEL_TAIL_SAMPLING_MAX_SPANS_PER_SECOND:-250}
BASEROW_OTEL_USER_METRICS_CARDINALITY_LIMIT: ${BASEROW_OTEL_USER_METRICS_CARDINALITY_LIMIT:-50000}
BASEROW_OTEL_USER_METRICS_FLUSH_INTERVAL: ${BASEROW_OTEL_USER_METRICS_FLUSH_INTERVAL:-60s}
BASEROW_OTEL_USER_METRICS_SERIES_EXPIRATION: ${BASEROW_OTEL_USER_METRICS_SERIES_EXPIRATION:-5m}
volumes:
- $PWD/deploy/otel/otel-collector-config.yaml:/etc/otel-collector-config.yaml
networks:
local:
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_OTEL_COLLECTOR_PORT:-4318}:4318"
embeddings:
profiles: ["ai"]
build:
context: ./embeddings
dockerfile: Dockerfile
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_EMBEDDINGS_PORT:-7999}:80"
networks:
local:
restart: unless-stopped
healthcheck:
test:
[
"CMD",
"python",
"-c",
"import urllib.request; urllib.request.urlopen('http://localhost/health', timeout=5)",
]
interval: 1m30s
timeout: 10s
retries: 3
ai-evals-db-init:
profiles: ["ai-evals"]
image: pgvector/pgvector:pg${POSTGRES_IMAGE_VERSION:-14}
environment:
- PGHOST=db
- PGUSER=${DATABASE_USER:-baserow}
- PGPASSWORD=${DATABASE_PASSWORD:?}
command: sh -c "createdb phoenix || true; createdb baserow_evals || true"
depends_on:
db:
condition: service_healthy
networks:
local:
restart: "no"
phoenix:
profiles: ["ai-evals"]
image: arizephoenix/phoenix:version-20.16.0
environment:
- PHOENIX_SQL_DATABASE_URL=postgresql://${DATABASE_USER:-baserow}:${DATABASE_PASSWORD:?}@db:5432/phoenix
# Provider keys for the Phoenix prompt playground (same vars the evals use).
- GROQ_API_KEY=${GROQ_API_KEY:-}
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
- GEMINI_API_KEY=${GEMINI_API_KEY:-}
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_PHOENIX_PORT:-6060}:6006"
networks:
local:
restart: unless-stopped
depends_on:
db:
condition: service_healthy
ai-evals-db-init:
condition: service_completed_successfully
assistant-eval-runner:
image: baserow_backend:dev
user: "${UID}:${GID}"
profiles: ["ai-evals"]
restart: unless-stopped
command: "watch-py manage assistant_eval_runner --host 0.0.0.0"
healthcheck:
test: ["CMD-SHELL", "curl --fail http://localhost:8090/healthz || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 3m
environment:
- SECRET_KEY=${SECRET_KEY:?}
- DATABASE_NAME=baserow_evals
- DATABASE_USER=${DATABASE_USER:-baserow}
- DATABASE_PASSWORD=${DATABASE_PASSWORD:?}
- DATABASE_HOST=db
- REDIS_HOST=redis
- REDIS_PASSWORD=${REDIS_PASSWORD:?}
- BASEROW_ASSISTANT_PHOENIX_URL=${BASEROW_ASSISTANT_PHOENIX_URL:-http://phoenix:6006}
- BASEROW_ASSISTANT_PHOENIX_PUBLIC_URL=${BASEROW_ASSISTANT_PHOENIX_PUBLIC_URL:-http://localhost:${BASEROW_PHOENIX_PORT:-6060}}
- BASEROW_ASSISTANT_PHOENIX_API_KEY=${BASEROW_ASSISTANT_PHOENIX_API_KEY:-}
- BASEROW_EMBEDDINGS_API_URL=${BASEROW_EMBEDDINGS_API_URL:-}
- GROQ_API_KEY=${GROQ_API_KEY:-}
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
- GEMINI_API_KEY=${GEMINI_API_KEY:-}
- GOOGLE_API_KEY=${GOOGLE_API_KEY:-}
- OPENROUTER_API_KEY=${OPENROUTER_API_KEY:-}
- BASEROW_EVAL_GIT_BRANCH=${BASEROW_EVAL_GIT_BRANCH:-}
- BASEROW_EVAL_GIT_COMMIT=${BASEROW_EVAL_GIT_COMMIT:-}
- BASEROW_EVAL_JUDGE_MODEL=${BASEROW_EVAL_JUDGE_MODEL:-}
- BASEROW_EVAL_CASE_TIMEOUT=${BASEROW_EVAL_CASE_TIMEOUT:-}
- BASEROW_EVAL_RUNNER_LOG_LEVEL=${BASEROW_EVAL_RUNNER_LOG_LEVEL:-}
ports:
- "${BASEROW_HOST_PUBLISH_IP:-127.0.0.1}:${BASEROW_EVAL_RUNNER_PORT:-8090}:8090"
volumes:
- ./docs:/baserow/docs
- ./backend:/baserow/backend
- ./premium/backend/:/baserow/premium/backend
- ./enterprise/backend/:/baserow/enterprise/backend
- ./deploy/plugins:/baserow/plugins
networks:
local:
depends_on:
db:
condition: service_healthy
ai-evals-db-init:
condition: service_completed_successfully
phoenix:
condition: service_started
stdin_open: true
tty: true
volumes:
pgdatadev:
node_modules:
nuxt:
storybook:
cache: