# Self-Hosting

> Run adTraces with Docker Compose.

adTraces is a Next.js application with a Postgres database. The Compose file starts both.

```bash
cp .env.example .env     # set POSTGRES_PASSWORD, SESSION_SECRET, LLM_API_KEY, APP_URL
docker compose up --build -d
curl http://localhost:3000/api/health
```

The app listens on port 3000 and Postgres on `127.0.0.1:5433`. On start the entrypoint applies the database migrations and the workflow bootstrap. The first registered user becomes instance admin.

This documentation was rendered for `https://adtraces.adfactory.app`. Set `APP_URL` to the public origin of your instance; it is used for share links, CLI login links, cookies, the sitemap and these docs.

## Local development

```bash
docker compose up -d db
pnpm db:migrate && npx bootstrap
pnpm dev
```

Set `DATABASE_URL`, `WORKFLOW_TARGET_WORLD=@workflow/world-postgres` and `WORKFLOW_POSTGRES_URL` as in `.env.example`.

## Operations

- Back up the Postgres volume.
- `GET /api/health` is the liveness check. `POST /api/health/workflow`, then `GET /api/health/workflow?runId=...`, tests the workflow engine that generates summaries.
- Put a TLS-terminating reverse proxy in front and set `APP_URL` to the `https://` origin.

See [Configuration](/docs/self-hosting/configuration) for all variables.
