Installing and updating
Hearth is one Go program, hearth, shipped as a container image. It
keeps its data in Postgres, its sessions and live events in Valkey, and
files on disk or in an S3 bucket. Everything else (the office editor,
the virus scanner, search by meaning, calls, the password vault) is an
optional service beside it.
These steps use Docker Compose on one Linux server. For Kubernetes, see Kubernetes at the end.
Requirements
For Hearth with the core services only, start with:
- 2 processor cores and 4 GB of memory for Hearth, plus 2 GB for Postgres (the limits the reference deployment gives them);
- disk for the files, plus about 20% for versions and trash;
- Docker Engine 24 or later with the Compose plugin;
- a domain name for Hearth and a reverse proxy that gets certificates for it (examples below).
Each optional service adds to that:
| Service | What it gives | Memory |
|---|---|---|
| A jobs container | background work kept apart from people's requests | 6 GB |
| Hearth Office | editing Word, Excel and PowerPoint files; converting them to PDF | 4 GB |
| ClamAV | the virus scan on upload | 5 GB |
| Qdrant | search by meaning (needs a model through LiteLLM) | 1 GB |
| LanguageTool | spelling and grammar in Office | 1.5 GB |
| Vaultwarden | Passwords | 256 MB |
| LiveKit | calls in Talk | 1 GB |
Hearth is tested with Postgres 18 and Valkey 9. Postgres needs the
pg_trgm extension available (it is part of the standard images).
Building the image
Hearth is built from source. The build compiles the web app, the Go server and the helper engines (PDF, pictures, text recognition, Typst) from source, so the first build takes a long time; later builds reuse Docker's caches.
Clone the Hearth repository and the PDF engine repository next to each other (use the addresses you were given access to):
git clone https://git.example.org/hearth/hearth.git git clone https://git.example.org/hearth/hearth-pdfcraft.gitBuild, giving the engine's git folder as a build context:
cd hearth docker build --build-context pdfcraft-git=../hearth-pdfcraft/.git \ --build-arg REVISION=$(git rev-parse --short HEAD) -t hearth:local .
The build checks the first page's size budget and fails rather than produce a slow image. Base images are pinned by digest, so two builds of the same commit give the same result.
Preparing the folder
Make a folder for the deployment, for example /srv/hearth, with this
layout:
/srv/hearth/
docker-compose.yml
.env
postgres/postgresql.conf
secrets/master.key
data/files/
data/sync-lineage/
Copy
deploy/postgres/postgresql.conffrom the repository intopostgres/. It is sized for a 2 GB Postgres container; raiseshared_buffersandeffective_cache_sizewith the memory you give it.Make the master key. It seals secrets in the database (two-factor secrets, external storage passwords, encryption keys). Keep a copy somewhere safe: without it those secrets cannot be read again.
mkdir -p secrets data/files data/sync-lineage openssl rand -hex 32 > secrets/master.key chmod 600 secrets/master.keyGive the data folders to the user the container runs as (65532):
sudo chown -R 65532:65532 data/files data/sync-lineage secrets/master.key sudo chmod 700 data/sync-lineage
data/sync-lineage must stay out of your backups and must never be
restored. Hearth uses it to notice that the database was put back from
a backup, and then tells every sync app to compare its folders again
(Backups and restore).
The compose file
This is a working starting point with Hearth, its Postgres and its
Valkey. Replace hearth.example.org with your address.
name: hearth
services:
hearth:
image: hearth:local
restart: unless-stopped
env_file: .env
environment:
PUBLIC_URL: https://hearth.example.org
DATABASE_URL: postgres://hearth:${POSTGRES_PASSWORD}@hearth-postgres:5432/hearth?sslmode=disable
VALKEY_URL: redis://default:${VALKEY_PASSWORD}@hearth-valkey:6379/0
MASTER_KEY_FILE: /run/hearth/master.key
STORAGE: local
STORAGE_DIR: /data/files
SYNC_LINEAGE_DIR: /data/sync-lineage
# The gateway of the network below: the proxy's connections
# arrive from it.
TRUSTED_PROXIES: 172.31.184.1
# The engines inside the image.
FFMPEG_PATH: /usr/local/bin/ffmpeg
PDF_ENGINE: /usr/local/bin/hearth-pdf
PDF_MODELS_DIR: /usr/local/share/hearth-pdf/models
PDF_FONTS_DIR: /usr/local/share/typst/fonts
IMAGE_ENGINE: /usr/local/bin/hearth-image
OCR_HELPER: /usr/local/bin/hearth-ocr
OCR_MODELS_DIR: /usr/local/share/hearth-ocr/models
TYPST_ENGINE: /usr/local/bin/typst
TYPST_FONTS: /usr/local/share/typst/fonts
volumes:
- ./data/files:/data/files
- ./data/sync-lineage:/data/sync-lineage
- ./secrets/master.key:/run/hearth/master.key:ro
ports:
- 127.0.0.1:8080:8080
depends_on:
hearth-postgres:
condition: service_healthy
hearth-valkey:
condition: service_healthy
healthcheck:
test: ["CMD", "/hearth", "healthcheck"]
interval: 30s
timeout: 5s
retries: 3
start_period: 20s
mem_limit: 4g
hearth-postgres:
image: postgres:18-alpine
restart: unless-stopped
command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
environment:
POSTGRES_USER: hearth
POSTGRES_DB: hearth
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
volumes:
- ./data/postgres:/var/lib/postgresql
- ./postgres:/etc/postgresql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hearth -d hearth"]
interval: 10s
retries: 10
shm_size: 256m
stop_grace_period: 60s
mem_limit: 2g
hearth-valkey:
image: valkey/valkey:9-alpine
restart: unless-stopped
command: ["sh", "-c", "exec valkey-server --requirepass \"$$VALKEY_PASSWORD\" --appendonly yes --save '' --maxmemory 256mb --maxmemory-policy noeviction"]
environment:
VALKEY_PASSWORD: ${VALKEY_PASSWORD:?set VALKEY_PASSWORD in .env}
volumes:
- ./data/valkey:/data
healthcheck:
test: ["CMD-SHELL", "REDISCLI_AUTH=\"$$VALKEY_PASSWORD\" valkey-cli ping | grep -qx PONG"]
interval: 10s
retries: 10
mem_limit: 320m
networks:
default:
ipam:
config:
- subnet: 172.31.184.0/24
gateway: 172.31.184.1
Pin the Postgres and Valkey images to exact versions (or digests) once you have chosen them, so an update is always a decision you make.
Put the passwords in .env beside the compose file:
POSTGRES_PASSWORD=<openssl rand -hex 24>
VALKEY_PASSWORD=<openssl rand -hex 32>
Every other setting is described in the configuration reference. A wrong value stops Hearth at start with every mistake listed at once, so you can fix them in one go.
Starting Hearth
Start the services:
docker compose up -dHearth applies its database migrations before it starts serving.
Check that it is ready:
curl -fsS http://127.0.0.1:8080/readyz/healthzanswers as soon as the process runs;/readyzanswers only when Postgres, Valkey, the file store and the event stream all work.Make the first administrator. The password is read from standard input so it never appears in the process list or your shell history:
docker compose exec -T hearth /hearth user create \ --username admin --email admin@example.org --admin < admin-password.txt rm admin-password.txtOpen
https://hearth.example.org(after setting up the proxy below) and sign in. Go to Administration to invite people, set up sign-in and choose the security policies.
Running background work apart
On a server with more than a handful of people, run two containers of
the same image: one answers people (HEARTH_ROLE=web), the other does
every background job (HEARTH_ROLE=jobs): indexing, previews made
ahead, text recognition, imports, backups and timed jobs. Give the
jobs container its own memory limit and a lower processor weight, so
heavy work never slows the web pages.
hearth:
# as above, plus:
environment:
HEARTH_ROLE: web
hearth-jobs:
image: hearth:local
restart: unless-stopped
env_file: .env
environment:
# the same settings as hearth, then:
HEARTH_ROLE: jobs
volumes:
# the same volumes as hearth
depends_on:
hearth:
condition: service_healthy
cpu_shares: 256
mem_limit: 6g
A YAML anchor (x-hearth-environment: &env and <<: *env) keeps the
two lists of settings the same. The jobs container serves only
/healthz and /readyz on its LISTEN address and needs no port on
the host.
The reverse proxy
Hearth listens on plain HTTP and expects a proxy in front for HTTPS. Whatever proxy you use, it must:
- pass the live event stream (
text/event-stream) without buffering; - allow request bodies of any size (uploads are sent in chunks, but a WebDAV client may send a whole file at once);
- allow long requests (an hour), for large downloads and the event stream;
- set
X-Forwarded-Forfrom the real client. Hearth believes the header only from the addresses inTRUSTED_PROXIES. Without that setting, every visitor looks like the proxy: the sign-in limit per network, the audit log and the signing trail all record the wrong address.
When the proxy runs on the Docker host, its connections come from the
gateway of the Docker network Hearth is on (172.31.184.1 in the
example). If the container is on several networks, list every gateway.
Caddy
hearth.example.org {
encode zstd gzip
reverse_proxy 127.0.0.1:8080
}
Caddy gets the certificate, flushes the event stream as it comes and
sets X-Forwarded-For itself.
Traefik
With Traefik in Docker, label the hearth service and put it on
Traefik's network (then list that network's gateway, or Traefik's
address, in TRUSTED_PROXIES):
labels:
traefik.enable: "true"
traefik.http.routers.hearth.rule: Host(`hearth.example.org`)
traefik.http.routers.hearth.entrypoints: websecure
traefik.http.routers.hearth.tls.certresolver: letsencrypt
traefik.http.services.hearth.loadbalancer.server.port: "8080"
traefik.http.middlewares.hearth-compress.compress: "true"
traefik.http.routers.hearth.middlewares: hearth-compress
Traefik streams responses and sets no body limit by default. Raise the entry point's timeouts for long uploads:
# traefik.yml
entryPoints:
websecure:
address: ":443"
transport:
respondingTimeouts:
readTimeout: 3600s
writeTimeout: 3600s
idleTimeout: 3600s
nginx
server {
listen 443 ssl;
http2 on;
server_name hearth.example.org;
ssl_certificate /etc/letsencrypt/live/hearth.example.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/hearth.example.org/privkey.pem;
client_max_body_size 0;
proxy_request_buffering off;
proxy_buffering off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
}
}
server {
listen 80;
server_name hearth.example.org;
return 301 https://$host$request_uri;
}
Set X-Forwarded-For to $remote_addr, not
$proxy_add_x_forwarded_for: the second keeps whatever the client sent,
and a client could then choose the address Hearth records.
The other services' addresses
Hearth Office, Vaultwarden and LiveKit each need an address of their own, through the same proxy:
| Service | Example address | Notes |
|---|---|---|
| Hearth Office | office.example.org |
WebSockets for co-editing; allow framing only by Hearth: Content-Security-Policy: frame-ancestors 'self' https://hearth.example.org |
| Vaultwarden | vault.example.org |
for Bitwarden's apps; refuse /admin from outside |
| LiveKit | calls.example.org |
WebSockets for signalling; media on its own UDP and TCP ports, not through the proxy |
Their set-up is described in Office, Passwords and Calls.
Updating
Read the release notes for settings that are new or required.
Pull the new source and build the image again (same command as above).
Dump the database first:
docker compose exec -T hearth-postgres pg_dump -U hearth -Fc hearth > hearth-$(date +%F).dumpRecreate the Hearth containers:
docker compose up -d hearth hearth-jobsMigrations run at start. Several containers can start at once: one migrates while the others wait for it.
Check
/readyzagain.
When something is wrong, go back to the previous image tag and restore the dump. Hearth never migrates a database back down, so an older Hearth should not run on a database a newer one has migrated. Upgrades and migrations has the details.
A running Hearth stops gracefully: on SIGTERM it reports itself not
ready, ends the event streams (browsers reconnect by themselves) and
gives uploads in flight SHUTDOWN_SECONDS (30 by default) to finish.
Kubernetes
A Helm chart is in deploy/kubernetes/hearth. Pods keep nothing of their
own: sessions and live events are in Valkey, metadata in Postgres and
files in S3 (STORAGE=s3). You provide Postgres, Valkey and the bucket.
helm install hearth deploy/kubernetes/hearth -f my-values.yaml
- Migrations run in a Job before each install or upgrade; the pods start
with
MIGRATE_ON_START=false. - Postgres's
max_connectionsmust cover every pod's pool during a rolling update: (most replicas + 2) x (DATABASE_MAX_CONNS+ 5) + 5. The chart setsDATABASE_MAX_CONNSto 10, so six pods need 125. - Do not put pgbouncer in transaction mode in front of Hearth. It holds advisory locks and listens for notifications on its own connections, which transaction pooling breaks.
SYNC_LINEAGE_DIRneeds a ReadWriteMany volume of your own (syncLineage.claimName), shared by every pod and the migration Job and kept out of backups.- Plain settings go under
config, secret ones in a Secret (secrets.existingSecret); the master key and the S3 secret key are mounted as files. - The ingress is set up for nginx with buffering off and no body limit.