Skip to content

Latest commit

 

History

History
169 lines (114 loc) · 10.2 KB

deployment.md

File metadata and controls

169 lines (114 loc) · 10.2 KB

Deployment

The server is one container, devforth/exceptic, for amd64 and arm64. All its data is in /data.

Image tags: latest (newest release), X.Y (newest patch of a minor version), X.Y.Z. Pin X.Y or X.Y.Z in production and upgrade on purpose.

Docker Compose

  1. Copy compose.yml to the server and set its image to the version you start with (devforth/exceptic:X.Y).

  2. Next to it create .env (every setting: Configuration):

    PUBLIC_URL=https://errors.example.com
    ADMIN_PASSWORD=<your password>
    SECRET_KEY=<openssl rand -hex 32>   # encrypts chat tokens; generated into /data when not set

    With an https:// PUBLIC_URL the login works only over HTTPS: set up the proxy first (HTTPS and a reverse proxy). To try it on plain http, use PUBLIC_URL=http://<server>:8000 and publish "8000:8000".

  3. On a machine without a proxy, with an https:// PUBLIC_URL (not for the try over plain http), add COMPOSE_PROFILES=caddy to .env (Caddy from compose.yml). Run docker compose up -d, open https://errors.example.com and log in as exceptic. The password is ADMIN_PASSWORD. A form opens where you create the first admin with your email and your own password.

  4. On the Projects page add a project and give its DSN to your app: Connecting apps.

The container runs as an unprivileged user (uid 65534). A bind-mounted data folder must be writable by it: sudo chown 65534:65534 ./data. A named volume, as in the example, needs nothing.

GET /health answers 200 while the server works, and 503 once the database cannot be read or its writes fail (a full disk); Docker uses it too (docker ps shows healthy).

HTTPS and a reverse proxy

Use HTTPS whenever the server is reachable from other machines. HTTPS is set up in a reverse proxy on the same machine (Caddy, nginx), not in Exceptic, and its certificate needs a domain.

  • compose.yml publishes the port only on 127.0.0.1, so only the proxy reaches it. Keep it so: never publish "8000:8000" behind a proxy.
  • Set PUBLIC_URL=https://errors.example.com. Nothing else is needed: the server then takes each person's address from the last X-Forwarded-For entry, the one the proxy added, and only from the proxy on this machine (in Docker: the address the published port comes from), so the login limit counts everyone apart and nobody can write an address of their own (programs on this machine reach the port as the proxy does). If something reaches the server past the proxy, or another address sends the header, it says so in its log.
  • The proxy passes the domain (Host), appends the address to X-Forwarded-For and sets X-Forwarded-Proto, and allows request bodies up to 20 MB. Caddy does all of it by itself.

Caddy from compose.yml

When the machine has no proxy yet, add COMPOSE_PROFILES=caddy to .env: every docker compose command (up, pull, down) then includes Caddy beside Exceptic, run as caddy reverse-proxy (Caddy's own reverse proxy, without a Caddyfile). It gets the certificate for PUBLIC_URL's domain itself, renews it and keeps it in the caddy-data volume. Without the profile it never starts, so a machine with nginx keeps using its own.

  • PUBLIC_URL is https:// and the domain only, as in the example: no / or path at the end, or Caddy does not start (paths are not allowed in docker compose logs caddy).
  • The domain points to this server, and ports 80 and 443 are free and open: Caddy uses the host's network (network_mode: host, Linux), so it reaches Exceptic as a proxy installed on the machine would, and nothing else is needed.

A proxy on the machine

Caddy:

errors.example.com {
	reverse_proxy 127.0.0.1:8000
}

nginx:

server {
    listen 443 ssl;
    server_name errors.example.com;
    # ssl_certificate ...

    client_max_body_size 20m;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Other setups

  • The proxy is on another machine, in a container of its own on a Docker network (not compose.yml's Caddy, on the host's), or Exceptic runs with network_mode: host or in Kubernetes: set TRUSTED_PROXIES to the proxy's address, e.g. TRUSTED_PROXIES=10.0.0.5. It replaces the default. List only proxies, never a whole range such as 172.16.0.0/12. A proxy in a container needs a fixed address (ipv4_address in Compose).
  • Cloudflare in front: keep the default and have your proxy send the visitor's address. compose.yml's Caddy cannot (it takes no settings), so run your own Caddy or nginx. In Caddy, put Cloudflare's ranges in trusted_proxies and add header_up X-Forwarded-For {client_ip}. In nginx, use set_real_ip_from with Cloudflare's ranges and real_ip_header CF-Connecting-IP.
  • The proxy does not set X-Forwarded-For (a plain TLS tunnel): set TRUSTED_PROXIES=none.

Securing it

  • Apps send errors to /api/<project id>/envelope/. It must stay reachable for them (and for browsers, if you monitor a frontend). It accepts only requests with the project's key.
  • Limit the UI, REST API and MCP to your office or VPN with ALLOWED_IPS.
  • Passwords, cookies and tokens are removed from incoming errors and logs before they are stored. The queue on disk keeps envelopes as the apps sent them until they are stored and the queue is compacted, and a backup taken meanwhile holds them too (Ingest).
  • Two roles: admin (everything: every project, users, settings, deleting) and user (issue statuses, logs, projects, notifications and users within their projects, and their own coding agents; not deleting projects or data, nor disk shares). A user sees only the projects given to them. Add users on the Users page: Users.
  • After 10 wrong passwords in 15 minutes a login is blocked until the window ends. Browsers the user logged in from before can still log in.

Resources

Minimum Recommended
CPU 1 vCPU 2 vCPU for many busy projects
Memory 512 MB the same
Disk 1.5 × MAX_DATABASE_SIZE (under a flood the files reached 1.4 times it: the queue on disk and deleted data not yet compacted), plus the backups kept in /data/backups the same, on an SSD

Give the container 512 MB: compose.yml sets mem_limit: 512m, with docker run add --memory 512m. The server sizes its memory and its queue by that limit, and needs no more; without a limit it keeps to a smaller default whatever the machine has (GOMEMLIMIT, Ingest).

How much the server can store at most, by CPU, in a 512 MB container: the most errors a minute it kept storing for 10 minutes without falling behind. Each error was about 16 KB (a stack trace with source, 10 breadcrumbs, user, tags, request). This is close to the worst case: 3 in 4 errors were new. Repeated errors cost less: an issue stores up to 10 of its errors a minute and only counts the rest.

CPU 1 2
Errors a minute, all projects together 20,000 40,000
Data a minute 315 MB 630 MB

Memory does not change these numbers: with 1 CPU, 256 MB stored as much as 512 MB. It matters once the database is full and the cleanup compacts it: writes wait meanwhile and envelopes are held in memory, so a smaller container refuses sooner (Ingest).

Logs sent along take their share: with 5 logs per error, about a quarter fewer errors.

Above that, apps pause for a few seconds and then send again. What they drop meanwhile shows on the Projects page. A project that sends more than its part of the queue is paused alone (Ingest).

Backup and restore

docker compose run --rm exceptic backup

It writes a copy to /data/backups/<time> while the server runs. Copy it off the server:

docker compose cp exceptic:/data/backups ./backups

Never copy /data/leveldb of a running server by hand: such a copy may not open.

To restore, stop the server and replace the data with the backup:

docker compose stop exceptic
docker run --rm -v <project>_data:/data -v "$PWD/backups/<date>:/backup:ro" alpine \
  sh -c 'rm -rf /data/leveldb && cp -a /backup/. /data/ && chown -R 65534:65534 /data'
docker compose start exceptic

docker volume ls shows the volume's name.

Upgrades

docker compose pull && docker compose up -d

This brings the newest patch of your X.Y. For a new minor version change the tag first.

On stop the server finishes the requests in progress, writes the queue it holds in memory to disk (Ingest) and sends the notifications still waiting. compose.yml gives it 30 s; with docker run add --stop-timeout 30.

Sign in with Google

Users added by an admin can also sign in with Google. Nobody can sign up that way.

  1. In Google Cloud, APIs & Services › Credentials, create an OAuth client ID of type Web application with the authorized redirect URI <PUBLIC_URL>/auth/google/callback (for example https://errors.example.com/auth/google/callback).
  2. Set GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET and PUBLIC_URL, and restart.

The first Google sign-in links the Google account to the user with the same email. Add users only with addresses that are theirs now: someone who left a company may still have a Google account made with their work email.

Forgotten password

docker compose stop exceptic
docker compose run --rm exceptic reset-password          # the only admin
docker compose run --rm exceptic reset-password <email>
docker compose start exceptic

It prints a temporary password; the user chooses a new one at the next login.

Logs

docker compose logs -f shows the settings at start, warnings and errors; more with LOG_LEVEL. Docker keeps a container's logs until it is removed, so compose.yml keeps at most 3 files of 10 MB (json-file); with docker run add --log-opt max-size=10m --log-opt max-file=3.