# Self-hosting

> Run the Lanekeeper team server inside your own network with Docker Compose: sign-in, team sync, the dashboard and the API on your own hardware.

Availability: Preview.

The self-hosted server runs the same API and the same team sync as the hosted service, on Node with SQLite.
Sign-in, organizations, members and invites, API tokens, single sign-on, Slack, billing, policies, pull-request
checks and live team sync (each machine's lanes, clashes and claims) all work. It runs on a single node: rooms and
rate limits live in that process.

## Run it

From the repository root:

```sh
API_URL=https://lanekeeper.internal \
APP_URL=https://app.lanekeeper.internal \
SECRETS_KEY="$(openssl rand -base64 32)" \
docker compose up -d
```

Data lives on the `lanekeeper-data` volume: the API's SQLite database, one file per repository's room under
`rooms/`, and the daily audit log archives under `audit/`. Schema changes apply on start. The image runs as an
unprivileged user and has a health check (`/v1/health`).

| Variable | Meaning |
|---|---|
| `API_URL` | The server's public URL. |
| `APP_URL` | Where the dashboard is served (CORS, and the origin sign-ins must come from). |
| `SECRETS_KEY` | 32+ random characters; encrypts stored secrets. Needed for SSO and Slack. |
| `GITHUB_CLIENT_ID`, `GITHUB_CLIENT_SECRET` | A GitHub OAuth app, for GitHub sign-in. |
| `TRUST_PROXY=1` | Only behind a reverse proxy that appends the client to `X-Forwarded-For`, so rate limits apply per client. |
| `PORT` | The published port (default 8080). |
| `LANEKEEPER_BIND` | The host address the port is published on (default `127.0.0.1`, this machine only). |
| `LOG_REQUESTS=0` | Stop the one-JSON-line-per-request log on stdout. |

Point everything at it: `lk login --server https://lanekeeper.internal`, the GitHub Action's `cloud-api-url`, and
the dashboard's `VITE_API_URL`.

## Network

The server speaks plain HTTP, so Compose publishes it on `127.0.0.1` only: put a TLS reverse proxy on the same
host in front of it and set `TRUST_PROXY=1`. Only if the proxy runs on another machine, set `LANEKEEPER_BIND` to an
address it can reach (`0.0.0.0` for all) and firewall the port to the proxy. Org admins can set an SSO issuer: the server refuses internal IP addresses, but it can't tell
that a public DNS name resolves to an internal one. If admins aren't fully trusted, limit the server's outbound
access.
