> ## Documentation Index
> Fetch the complete documentation index at: https://docs.backtale.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Backtale with Docker Compose

> Start the verified 1.0.0 digest with Docker Compose, bundled Postgres 17, migrate-on-boot, and a TLS proxy in front of port 3000.

Docker Compose runs one Backtale replica and Postgres with pgvector on a single machine. Start the image you already [verified](https://docs.backtale.app/install/verify.md). Do not build from source: without `--no-build`, Compose builds the local folder and ignores the digest you checked.

The shipped database image is `pgvector/pgvector:pg17`. The app listens on port 3000 and, with the default Compose file, is published on `127.0.0.1` only.

## Generate the env file

From a copy of the product repository (the `scripts/install/generate.mjs` that ships with the release):

```bash theme={null}
node scripts/install/generate.mjs env --base-url https://backtale.example.com --proxy-hops 1
```

That writes `.env` and does not overwrite a file that already exists. It sets:

* `POSTGRES_PASSWORD` and `AUTH_SETUP_TOKEN` (64 hex characters each)
* `TOKEN_ENCRYPTION_KEY` (base64 of 32 random bytes)
* `APP_BASE_URL` from `--base-url`
* `AUTH_TRUSTED_PROXY_HOPS` from `--proxy-hops` (use `1` behind one TLS proxy)
* `AUTH_MODE=profile` and `AUTH_PROFILE=local`

Back up `TOKEN_ENCRYPTION_KEY` outside the machine. A database dump cannot recover encrypted AI and tracker secrets without it.

You can fill the same values by hand from `.env.example`. `POSTGRES_PASSWORD` is `openssl rand -hex 32`. `TOKEN_ENCRYPTION_KEY` is `openssl rand -base64 32`. `AUTH_SETUP_TOKEN` is at least 32 characters (`openssl rand -hex 32`). The stack refuses to start without `POSTGRES_PASSWORD`.

## Start the verified image

**1. Pin the digest**

Put this in `.env`, or export it for one command:

```bash theme={null}
BACKTALE_IMAGE=ghcr.io/rahilp/backtale@sha256:a4b6216589d14bd4be4deb7db4ed2f81ad28f65b76475135d741bab4c0d8721a
```

**2. Start without a build**

```bash theme={null}
docker compose up -d --no-build
```

Leave `BACKTALE_SKIP_MIGRATE` unset. On one replica the entrypoint runs `prisma migrate deploy` before the app serves. Logs should not show `boot_refused`. Check `http://127.0.0.1:3000/api/health` on the machine, then put TLS in front before anyone else uses it.

**3. Put TLS in front**

Keep port 3000 off the public internet. Use your own reverse proxy, or the optional overlay:

```bash theme={null}
docker compose -f docker-compose.yml -f docker-compose.tls.yml up -d --no-build
```

Set `APP_BASE_URL` to the public `https://` address with no trailing slash. Set `AUTH_TRUSTED_PROXY_HOPS` to the number of proxies between the browser and the app. The proxy must send `X-Forwarded-Proto` and `X-Forwarded-For`.

Then open `/setup`. See [First run](https://docs.backtale.app/install/first-run.md).

## Commands you will use

```bash theme={null}
docker compose exec app backtale doctor
docker compose exec app backtale license status
docker compose logs -f app
```

`docker compose config` prints secrets. Do not paste that output into a ticket.

## More than one replica

Run migrations once, then skip them on the long-running replicas:

```bash theme={null}
docker compose run --rm app backtale db migrate
```

Set `BACKTALE_SKIP_MIGRATE=true` on every app replica. Every replica must use the same `TOKEN_ENCRYPTION_KEY`. The server refuses to start while migrations are behind.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.