Set up a dohc server

Use this guide to run sync and sharing for your own devices and collaborators. Local work in dohc does not need a server or account. dohc Drive, the managed service at https://drive.dohc.computer, is in invite-only alpha.

The sections through Check before inviting other people set up a working server. The sections after it cover optional configuration and maintenance.

Choose who can reach the server

For public access, use a server with a domain name and inbound HTTPS access. Recipients can open your share links without joining your network. Workspace permissions still control their access.

For private access, use Tailscale on the server and each device that needs access. Sign each device into the intended tailnet. Enable MagicDNS and HTTPS certificates for the server's Tailscale hostname. Recipients need permission to reach the server through Tailscale before opening a share link. Tailscale does not grant access to a dohc workspace.

Both choices run the same dohc services. Keep the server running while other devices need sync or browser access. Local work remains available when the server is offline.

App publishing is disabled in the default self-host bundle. To turn it on, follow Publish apps.

Prepare the host

Install Git, Docker Engine with Linux container support, Docker Compose 2.24.4 or newer, and Node.js 24.16 or newer. Have an SMTP service ready for verification and password reset emails. The server emails share invitations through it too. The SMTP service must support TLS.

Get the Compose files and image

On a linux/amd64 host, clone the repository for the Compose files and setup scripts, then pull the prebuilt image:

git clone --depth 1 https://github.com/dohchq/dohc.git
cd dohc
docker pull ghcr.io/dohchq/dohc-self-host:latest

To pin a specific commit instead of latest, use ghcr.io/dohchq/dohc-self-host:COMMIT_SHA or a digest from the dohc-self-host package. For other architectures such as linux/arm64, or to build locally without pulling from GitHub Container Registry, build the deployment bundle instead.

Build the deployment bundle

The build machine needs Git and at least 40 GB of free disk space. Clone dohc and select the release you intend to deploy. From that clean checkout, build an image and deployment bundle:

node tools/self-host/release.mjs --image dohc-self-host:VERSION --output ../dohc-server --archive

Replace VERSION with the release or commit you are deploying. The command builds the services into an image; running containers do not need the source checkout or pnpm. The bundle records its source commit, image ID, and platform in release.json. It contains no deployment secrets.

Copy the bundle to your server. Check that the bundle's Linux architecture in release.json matches the deployment host. Open a terminal in the bundle directory, then load its image:

docker image load -i services.tar

If you built on the deployment host, use the image already loaded there. Keep the bundle's configuration and persistent volumes when you update dohc.

Create the configuration

For public access, run this command with your domain:

node tools/self-host/bootstrap.mjs init --origin https://dohc.your-domain.com --name "My dohc server" --image ghcr.io/dohchq/dohc-self-host:latest

For private access, use your server's Tailscale HTTPS hostname:

node tools/self-host/bootstrap.mjs init --origin https://your-server.your-tailnet.ts.net --mode private --name "My dohc server" --image ghcr.io/dohchq/dohc-self-host:latest

If you built the image from source or pinned a specific tag, pass that image name instead.

The command creates .env.self-host and generates the deployment secrets. It refuses to replace an existing configuration. Restrict access to this file; it contains credentials. Copy DOHC_SNAPSHOT_KEY to storage that does not depend on this server. Without that key, nobody can open the server's relay snapshots. Keep the snapshot key away from the server describes how to keep and replace the key.

Edit these SMTP settings and your approved email in .env.self-host:

DOHC_SMTP_HOST=smtp.your-provider.com
DOHC_SMTP_PORT=587
DOHC_SMTP_SECURE=false
DOHC_SMTP_USER=your-smtp-user
DOHC_SMTP_PASSWORD=your-smtp-password
DOHC_SMTP_FROM=dohc <dohc@your-domain.com>
DOHC_SIGN_UP_EMAILS=you@your-domain.com

Port 587 uses STARTTLS. For implicit TLS, use port 465 and DOHC_SMTP_SECURE=true. Use a sender address accepted by your SMTP provider. DOHC_SIGN_UP_EMAILS keeps sign-up closed to the addresses you list. To approve more people, see Choose who can create an account.

Print the network setup instructions:

node tools/self-host/bootstrap.mjs network

For direct public access, point your domain at the server and permit inbound TCP ports 80 and 443. If you use Cloudflare, follow Run behind Cloudflare instead. Caddy obtains and renews the HTTPS certificate.

For private access, follow the printed Tailscale Serve instructions on the deployment host. Check existing routes before changing them. The setup tool does not change your Tailscale configuration. The configured HTTPS address must also work from inside the relay container. The readiness check tests that connection and reports DNS, TLS, or routing failures. Before you add your own proxy in front of the relay, read Use your own proxy.

Decide before the first start

Make these two choices before the first start. This guide does not change either one afterward.

Start and check the server

node scripts/check-self-host.mjs --start

The deployment initializes fresh storage, applies authentication migrations, and starts the services. The start worked when the command ends with Self-host check summary and two equal numbers. A failed check starts with [missing]. Keep the deployment secrets and volumes across restarts. Do not rerun fresh initialization against an existing deployment.

First start with a data disk or an external database

With DOHC_DATA_DIRECTORY or DOHC_POSTGRES_HOST set, add --first-start for the first start only:

node scripts/check-self-host.mjs --start --first-start

Use --first-start only for a new, empty deployment. It cannot recover existing workspaces. A first start refuses unless all four disk folders are empty, and names each folder that holds data. With DOHC_POSTGRES_HOST set and no data disk, a first start refuses if the relay's Docker volumes already hold relay data.

After the first start, every start and upgrade refuses to run in these cases:

A start also refuses when Docker cannot complete these checks. The accounts check accepts any database that holds dohc accounts, including another deployment's, so check that POSTGRES_DB names this deployment's database. Without a data disk, the relay deployment stays in the Docker volumes on its original host, so start it there.

Connect the desktop app

  1. Open Settings → Sync and sharing and select Connect server.
  2. Enter the HTTPS address you configured above.
  3. Follow the browser sign-in flow.
  4. Create an account on your server and open the link in the email it sends.
  5. Approve the device after checking the displayed code.
  6. Return to dohc. Settings opens on Sync and sharing; turn on Sync this workspace.

The server account belongs to your server. A dohc Drive account is not required. The connection applies to this dohc installation; workspace permissions still determine what it can access.

On another device, connect to the same server and sign in to the same account. Copy the workspace code from Settings → Sync and sharing, then use it to join the existing workspace in a local folder.

Share work

Use the workspace's sharing controls to choose the work and the recipient's permissions. Share the resulting link. Anonymous access works only when the share permits it.

For a private server, recipients also need Tailscale network access. Changing the network route does not change a share's permissions.

Check before inviting other people

Create a test account and confirm that verification and password reset emails arrive. Connect a second desktop and confirm that an edit reaches it. Open a share link in a separate browser profile and check its permissions. Restart the services and confirm that the workspace remains available.

Keep a local copy of important work while testing your deployment. See the browser service operations reference for storage and permission boundaries.

Choose who can create an account

A nonempty DOHC_SIGN_UP_EMAILS list keeps sign-up closed to approved email addresses and pending invites. List the approved addresses in .env.self-host, separated by commas. Include your own address before the first start:

DOHC_SIGN_UP_EMAILS=you@your-domain.com,colleague@your-domain.com

With a list, the server also accepts an address that has a pending invite. A pending invite exists when someone shares work with an email address that has no verified account on the server. Revoking that share removes the invite.

A workspace invite link also admits a new account while sign-up is closed. The person opens the link, selects Create an account, and the sign-up page sends the link with the request. To stop invite links from creating accounts, set this in .env.self-host:

DOHC_INVITE_LINK_SIGN_UP=off

People who already have an account can still join through the link. The relay refuses to start if the value is anything other than on or off. The server ignores case and surrounding spaces when it compares addresses.

With a list, the sign-up page asks for no name or password. The server emails a link instead, and the person chooses their name and password there. Opening that link also verifies the address and signs out every session of the account. Until then, nobody can sign in to the account, and nobody else can choose the name other people see. An existing account that never verified its address works the same way: select Forgot your password? to get the link. When the server starts with a list, it signs out everyone whose email is not verified. To sign in again, they choose a password from an emailed link. People with a verified email stay signed in. Run one account service per database: an instance still running with open sign-up could issue new unverified sessions after this sign-out.

Any other address gets a message that the server creates accounts only for approved or invited addresses. Share links need no account, so closed sign-up does not change them. The server checks eligibility when it creates the account. Removing an address from the list later does not remove its account. Revoking an invite after its account exists does not remove that account either. Run node tools/self-host/bootstrap.mjs start to apply a changed list without stopping the server. Compose recreates only workspace-api while gateway, sync-relay, and share-web keep running, and the gateway holds requests during that restart. Leave DOHC_SIGN_UP_EMAILS empty to open sign-up again.

workspace-api asks sync-relay about pending invites over the internal Docker network. If the relay does not answer, an address outside the list gets a message to try again. Listed addresses can still sign up. Outside the self-host bundle, set WORKSPACE_API_RELAY_URL on workspace-api to the relay's internal origin. Both services must use the same BETTER_AUTH_SECRET.

Keep server data on an attached disk

To keep server data on an attached disk, set it up before the first start. You can then move the server to a new host by moving the disk. The disk holds the relay database with its files, the continuity record, the server's session host, and its copies of workspaces for automations and the phone. It also holds the working space for hourly snapshots. A snapshot runs only while the disk has free space for two copies of the relay database, plus headroom for the relay's own writes. Caddy's certificates stay in a Docker volume on the host. Accounts stay in a Docker volume on the host too, unless you keep them in an external Postgres. Docker names the accounts volume <DOHC_DEPLOYMENT_NAME>_dohc_self_host_postgres, which is dohc-self-host_dohc_self_host_postgres by default.

Mount the disk on the host, for example at /mnt/dohc-data, and make the mount persist across restarts. Create a deployment folder on the mounted disk with one folder for each kind of data. The services run as UID 1000 and need to own these folders:

sudo install -d -m 0700 -o 1000 -g 1000 /mnt/dohc-data/dohc/sync-relay /mnt/dohc-data/dohc/continuity /mnt/dohc-data/dohc/host-data \
  /mnt/dohc-data/dohc/snapshots

Create the snapshots folder even if you do not turn on snapshots.

Set the deployment folder in .env.self-host:

DOHC_DATA_DIRECTORY=/mnt/dohc-data/dohc

Name a folder on the disk, not the mount point. If the disk is not mounted, that folder is missing and the deployment fails to start. If a folder is missing, mount the disk. Never recreate the folders: a start on empty folders would create a new deployment. The setup and recovery commands add the data-disk Compose overlay when DOHC_DATA_DIRECTORY is set. Leave it empty to keep all data in Docker volumes on the host.

Set DOHC_DATA_DIRECTORY before the first start, and do not change it afterward. Docker keeps a volume's storage from when it created the volume. If an existing volume keeps its data elsewhere, the setup and move commands refuse to start. Restore the previous setting. Never remove the volume: it holds the deployment's data. This guide does not move existing volumes onto a disk.

Then start the server with --first-start. The disk setup passed when the check prints [ok] data disk volumes and [ok] relay deployment on the data disk.

Keep accounts in an external Postgres

By default, the deployment runs its own Postgres for accounts and sign-in sessions, in a Docker volume on the host. To keep them in a managed Postgres instead, set it up before the first start. A lost host or disk then loses no accounts. Relay data stays on the host or its attached disk either way.

The database must accept TLS connections. Every service verifies the database's certificate and host name against your provider's CA certificate. The setup has no option to turn this check off.

  1. Create a database for this deployment only, and a user that owns it. If your provider limits which addresses can connect, allow the server's address.

  2. Download your provider's CA certificate to the server. The services run as UID 1000 and need to read it:

    sudo install -D -m 0644 provider-ca.pem /etc/dohc/postgres-ca.pem
    
  3. Set the database in .env.self-host:

    DOHC_POSTGRES_HOST=db.your-provider.com
    DOHC_POSTGRES_PORT=5432
    DOHC_POSTGRES_CA_FILE=/etc/dohc/postgres-ca.pem
    POSTGRES_DB=dohc
    POSTGRES_USER=dohc
    POSTGRES_PASSWORD='your-database-password'
    

    Use the host name that the provider's certificate names. POSTGRES_DB and POSTGRES_USER can contain only letters, digits, underscores, hyphens and dots. POSTGRES_PASSWORD replaces the password that init generated. Keep it in single quotes: Docker Compose replaces $ and the name after it in an unquoted value.

With DOHC_POSTGRES_HOST set, the setup and recovery commands add the external-database Compose overlay. The deployment then does not start the bundled Postgres or create its volume. Migrations run against your database. Leave DOHC_POSTGRES_HOST, DOHC_POSTGRES_PORT and DOHC_POSTGRES_CA_FILE empty to use the bundled database.

Your provider's backups are the only backups of these accounts. A deployment archive does not include them. This guide does not move accounts from the bundled database to an external one.

Then start the server with --first-start. The database setup passed when the check prints [ok] compose startup. The services start only after the migrations finish. Every later start also prints [ok] accounts database.

Run behind Cloudflare

For a public server behind Cloudflare, set DOHC_BEHIND_CLOUDFLARE=1 in .env.self-host. The setup and recovery commands then add the Cloudflare gateway overlay. Leave it at 0 for direct public access or private Tailscale access. Caddy trusts only the shipped Cloudflare IPv4 and IPv6 ranges and reads CF-Connecting-IP from those peers. It forwards the resolved address to the services for their per-address rate limits. From any other peer, Caddy ignores client-address headers and uses the connection's address.

Give Cloudflare only the origin's IPv4 address through an A record. Do not configure an origin AAAA record. The Docker network is IPv4-only. IPv6 origin connections can arrive at Caddy from Docker's bridge gateway, losing the Cloudflare peer address. Those connections then share one address for rate limits. Cloudflare can still serve IPv6 visitors while connecting to the origin over IPv4.

Restrict inbound origin connections to Cloudflare's ranges using your provider's network firewall or Docker's DOCKER-USER chain. Docker's published-port rules run before ufw and firewalld rules. An allowlist in ufw or firewalld alone can leave port 443 open. DOCKER-USER filters only IPv4, so also block inbound IPv6 on ports 80 and 443 in the host firewall, or use the provider's firewall. Otherwise, a visitor can bypass Cloudflare and choose their own client-address headers. Caddy ignores those forged headers, but a direct connection still bypasses Cloudflare's controls.

Configure Cloudflare to bypass caching for all account, relay, and share responses, including responses marked private, no-store. Disable bot challenges for this hostname. The desktop app, the CLI, and agents with only a share link call it directly and cannot complete browser challenges. A Cloudflare-only allowlist also admits other Cloudflare customers who point their zone at this origin. They can bypass your zone's WAF and bot rules, and can choose the client address the services use for rate limits, for example through a Worker. Use a custom, zone-specific Authenticated Origin Pulls certificate to restrict access to your zone. A Cloudflare Tunnel is another option. Certificate setup, Authenticated Origin Pulls, and Cloudflare Tunnel configuration are not covered here yet. This overlay does not change Caddy's certificate handling.

The release reads tools/self-host/cloudflare-proxies.caddy locally and never fetches ranges at startup. To refresh it from Cloudflare's published lists, run this command from the checkout or release bundle:

node scripts/self-host/refresh-cloudflare-ranges.mjs

Update the origin firewall to match the refreshed ranges. Apply the updated trust file to the gateway:

node tools/self-host/bootstrap.mjs start

Publish apps

App publishing is disabled in the default self-host bundle. It needs its own HTTPS app domain and additional relay limits. Use a separate registrable domain that you control for apps. For example, serve the viewer at dohc.your-domain.com and apps under your-app-domain.net. App domains gives the full rules, including the private suffixes it permits. Follow the share-web operations reference before enabling it. Behind Cloudflare, the bundle can serve the app domain: see Serve published apps behind Cloudflare.

Apps use their approved datasets when DOHC_RELAY_APP_PUBLICATIONS=1 is enabled. Set DOHC_RELAY_APP_BACKEND_MAX_PARTICIPANTS_PER_GRANT to change the default limit of 1,000 submitting participants per app and share grant. Reading an app does not consume this limit. Uploads and write operations do. Workspace storage quotas still apply. The release includes the isolated app runtime. The release build checks its compiled child and Wasm dependencies before creating the image.

Serve published apps behind Cloudflare

Behind Cloudflare, the gateway can also serve published apps on their app domain. Choose the domain as described in App domains. Use the app domain only for published apps. Serve nothing else on it, including its apex.

  1. In Cloudflare, add a proxied wildcard A record for *.your-app-domain.net with the origin's IPv4 address. Do not add an AAAA record.

  2. Set the zone's SSL/TLS encryption mode to Full (strict). Cloudflare's Universal SSL certificate covers the app hosts at the edge.

  3. Create a Cloudflare Origin CA certificate for *.your-app-domain.net. Install the certificate and its private key on the server:

    sudo install -d -m 0700 /etc/dohc/app-tls
    sudo install -m 0644 app-origin.pem /etc/dohc/app-tls/cert.pem
    sudo install -m 0600 app-origin.key /etc/dohc/app-tls/key.pem
    
  4. Set these values in .env.self-host:

    DOHC_RELAY_APP_PUBLICATIONS=1
    DOHC_SHARE_WEB_APP_DOMAIN=your-app-domain.net
    DOHC_APP_TLS_CERT_FILE=/etc/dohc/app-tls/cert.pem
    DOHC_APP_TLS_KEY_FILE=/etc/dohc/app-tls/key.pem
    
  5. Bypass the cache and turn off bot challenges for the app hosts, as for the server's own host.

  6. Run sudo node tools/self-host/bootstrap.mjs start to apply the updated settings (with sudo so the command can read the root-owned certificate and key files).

To check the setup, publish an app from a connected desktop and open its share link in a browser. The app opens on a host under your app domain.

With DOHC_BEHIND_CLOUDFLARE=1 and an app domain, the setup and recovery commands add the Cloudflare app overlay. They refuse to run when the certificate or key setting is missing. They also refuse a certificate setting without Cloudflare and an app domain. Docker refuses to start the gateway when either file is missing, and never creates it.

The gateway serves each app host with the certificate you installed, and Caddy never requests one for those hosts. It sends app requests only to share-web, with the Host header unchanged. It sets the forwarded address, host, and protocol as on the server's own host, and answers 404 for /internal/ paths. Sign-in and the relay stay on the server's own host. DOHC_SHARE_WEB_PUBLIC_HOSTS keeps only that host. The server's own host still gets its certificate from Caddy's automatic HTTPS.

Only Cloudflare trusts an Origin CA certificate. Browsers do not. Keep the wildcard record proxied. Never turn off certificate checks in a client to reach the origin directly. To replace the certificate, install the new files at the same paths, then run sudo node tools/self-host/bootstrap.mjs start (so the command can read the root-owned certificate and key files).

Use your own proxy

If you add your own proxy in front of the relay, do not let it log the Authorization header. That header carries sign-in credentials and the credential your server syncs with to run your automations.

DOHC_GATEWAY_ADDRESS and DOHC_SHARE_WEB_ADDRESS in .env.self-host are the Docker network addresses of the gateway and share-web. If you change them, keep each one a single IPv4 address inside DOHC_NETWORK_SUBNET, with no hostname, CIDR range, or port. The bundle passes them to DOHC_AUTH_TRUSTED_PROXIES, DOHC_SHARE_WEB_TRUSTED_PROXIES, and DOHC_RELAY_TRUSTED_PROXIES. The sign-in service, workspace-api, trusts X-Forwarded-For from both addresses. share-web and the relay trust it only from the gateway. The relay reads it only for incoming webhook deliveries, to give each sender of a website form its own limit. Each service refuses to start when a trusted proxy entry is not an IP address.

workspace-api reads X-Forwarded-For only from a trusted proxy. If the forwarded address list is missing, invalid, or names only trusted proxies, the service uses the connecting proxy's address. The proxy section of the share-web operations reference describes the share-web rules.

Run automations on the server

The self-host bundle enables server automations with DOHC_RELAY_AUTOMATIONS=1. Schedules, Group messages, and button presses trigger automations while the desktop app is closed. The workspace must have synced, and the server must be its automation host. In the desktop app, choose This server under Settings > Advanced > Schedules run on. Automatically placed hosts move to the server at their next check-in, if the server has room. A computer the owner chose as host keeps that role until the owner changes it. Hosts recorded before automatic placement was introduced also stay where they are. Due times missed while no computer or server runs schedules do not run later.

Reserve additional disk space for each hosted workspace, about the size of that workspace again. The default workspace storage quota is 2 GiB. Server copies, engine databases, and run history contain unencrypted workspace content. Protect the dohc_self_host_host_data volume like the relay database. After a host move, an unused copy closes after one day and remains for 30 more days for run history.

The server hosts at most 64 workspaces and runs at most 4 automations concurrently, one per workspace. Each workspace can start a burst of 120 runs, then one run every 10 seconds, or 360 an hour. Excess runs wait. The owner receives a notice at most once a day when the workspace reaches its run limit. At the workspace limit, newly assigned schedules run on the owner's computer.

Check a running deployment with node scripts/check-self-host.mjs --running. The automation check reports whether the engine daemon is up and a replica pass has completed. Individual workspace failures appear in the sync-relay logs with their workspace IDs and do not take the server offline. An unavailable automation host fails this check even when sync and sharing remain available. If it fails, inspect the sync-relay logs and verify disk space and the relay's public HTTPS route.

Collect a website form

An incoming webhook can take a form on any website. Each response becomes a record in a private Collection. A form's address sits in the page, so anyone who loads the page can post to it. Make it a website form address so dohc limits what they can send.

  1. In Settings > Secrets > Incoming webhooks, choose New webhook.
  2. Turn on Website form.
  3. Under Fields to keep, list the form's field names, such as email, source.
  4. Choose Create webhook, then copy the example form into your page.
<form method="post" action="WEBHOOK_ADDRESS">
  <input name="email" type="email" required />
  <button type="submit">Join</button>
</form>

Agents create the same address with dohc webhook create Waitlist --collection waitlist --form-fields email,source.

A website form address works differently from a private one:

The record's title is the webhook name followed by the first of title, subject, summary, event, name, or email that has a value. The record keeps the response as text. For a website form, that is only the fields you listed. Without a script, the browser shows the webhook's JSON answer after submitting. A script on the page can send the same fields with fetch and read the answer: 202 when dohc accepted the response, 429 past a limit. Send them form-encoded, as new URLSearchParams(new FormData(form)), with no custom headers. dohc refuses a FormData body, and a JSON body needs a preflight that the address doesn't answer. Each webhook takes 500 deliveries a day. dohc doesn't check that a person, rather than a script, filled in the form. A script that changes networks can still send junk records up to the daily limit. Rotate the address in Settings > Secrets > Incoming webhooks to stop it. To change a website form's fields, create a new webhook and delete the old one.

Turn server automations off

Turning off automations deletes their server copies at startup, with each copy's claims and run history. Save a private deployment archive first if you need that history. The bundle cannot restore or view archived run history.

Set DOHC_RELAY_AUTOMATIONS=0 in .env.self-host. Apply the setting without stopping the rest of the deployment:

node tools/self-host/bootstrap.mjs start

A copy the phone has also read stays for one day after the restart or the phone's last read, then goes with its run history. With automations off, a read from the phone or a personal agent still makes a copy of the workspace under /host-data. That copy goes a day after the last read. At startup, the server ends the phone and personal-agent hold on a copy whose workspace has Show on phone turned off, or has a new owner. Such a copy goes at once unless an automation still uses it. To keep a workspace's phone reads off the server, turn off Show on phone for it in the phone's Settings. The synced workspace files remain in the relay. At the owner's next desktop check-in, schedules move back to that computer. Set DOHC_RELAY_AUTOMATIONS=1 and restart to enable server automations again.

Send iPhone alerts

The server can send alerts to the dohc phone app on iPhone through Apple Push Notification service (APNs). Alerts stay off until you set all five APNs settings. Without them the server starts as before.

APNs delivers alerts for the phone app only when they are signed with an APNs auth key that belongs to the Apple Developer team that publishes the app.

  1. In that Apple Developer account, create an APNs auth key and download its .p8 file. Apple lets you download the file only once.

  2. Keep a copy of the .p8 file away from the server, for example in your password manager. A deployment archive leaves the key out, so the server's backups do not hold it.

  3. Install the key on the server. The relay runs as UID 1000 and needs to read it:

    sudo install -D -o root -g 1000 -m 0640 AuthKey_ABC123DEFG.p8 /etc/dohc/apns-key.p8
    
  4. Set the APNs settings in .env.self-host:

    DOHC_RELAY_APNS_TOPIC=app.dohc.mobile
    DOHC_RELAY_APNS_ENVIRONMENTS=production
    DOHC_RELAY_APNS_KEY_FILE=/etc/dohc/apns-key.p8
    DOHC_RELAY_APNS_KEY_ID=ABC123DEFG
    DOHC_RELAY_APNS_TEAM_ID=XYZ987WVUT
    
    SettingValue
    DOHC_RELAY_APNS_TOPICThe phone app's bundle ID, app.dohc.mobile.
    DOHC_RELAY_APNS_ENVIRONMENTSproduction for TestFlight and App Store builds. production,sandbox to also send to development builds.
    DOHC_RELAY_APNS_KEY_FILEThe absolute path of the APNs auth key (.p8) on the server.
    DOHC_RELAY_APNS_KEY_IDThe key's 10-character Key ID, which Apple shows with the key.
    DOHC_RELAY_APNS_TEAM_IDThe Apple Developer team's 10-character Team ID, which Apple shows under Membership details.
  5. Run node tools/self-host/bootstrap.mjs start to apply the updated settings.

With any APNs setting set, the setup and recovery commands add the APNs Compose overlay. They refuse to run unless all five are set in the formats above and the key file exists. They also refuse a key file inside DOHC_DATA_DIRECTORY, and an archive refuses a key file inside any deployment volume, because the archive copies those folders. The overlay binds the key file read-only into the relay at /etc/dohc/apns-key.p8. Docker refuses to start the relay when the file is missing, and never creates it. The relay refuses to start when the file is not a P-256 private key.

To check the setup, open Settings in the phone app while signed in to this server. Alerts offers a switch. On a server without APNs, it says the server isn't set up to send alerts.

To turn alerts off, clear all five settings, then run node tools/self-host/bootstrap.mjs start. To replace the key, install the new file at the same path, update DOHC_RELAY_APNS_KEY_ID, then run node tools/self-host/bootstrap.mjs start.

Replace the Markdown reader

The amd64 and arm64 images include the Markdown reader. The relay refuses to start without it, because Edit shares need it. To override DOHC_ENGINE_READER_CONFIG, point its node, bundle and manifest fields at the absolute paths of root-owned regular files. Keep those files and their parent directories unwritable by the service user and other accounts.

Live editing limits

The live editing profile allows 384 connections in the relay and 192 per workspace. The relay keeps 16 of each for workspace owners, so other people share 368 in total and 176 per workspace. Each grant allows 80 connections, each principal 12, and each editing session 6. Everyone using one share link counts against its link grant. One browser or one agent connection holding that link has its own link principal. Named accounts count across their grants and devices. The browser gateway applies the same limits to its named and link routes.

A refused connection closes with the code of the limit it hit:

CodeLimit
live_total_limitConnections in the relay or gateway
live_workspace_limitConnections in one workspace
live_grant_limitConnections on one grant
live_person_limitConnections for one principal
live_session_limitConnections in one editing session
live_buffer_limitLive frame buffers

The relay holds at most 128 MiB of live frame buffers, and the browser gateway has a separate 128 MiB budget. Checking edits uses another 128 MiB pool in the relay and two validation processes, each with a heap of up to 512 MiB. The session host's document state and OS socket buffers use memory outside these budgets.

The relay refuses an edit whose document state and new edit total more than 16 MiB, or whose check needs more than the 128 MiB pool. When a check runs out of heap, the relay refuses the edit as too large and keeps running. A check that must wait for room gets a retry. An owner's refused edit is kept unapplied, and that document's later owner edits wait behind it. The owner can save a recovery copy of refused edits, even ones kept in an earlier copy of the workspace. If this build has not migrated that earlier copy, the session host copies it into .recovery in its data folder and migrates the copy. That needs free space of twice the earlier copy's size. The session host removes the copy after the save, or after one idle minute. The session host also checks a document before it starts live editing on it. When that check runs out of heap, the document shows Stopped by the server until its owner chooses Resume.

These limits fit 20 people with three documents open each, with capacity left for owners and other devices. They remain provisional until the launch server is measured. The numbers come from the live editing profile. Custom deployments must supply the same buffer budget to all live routes.

Back up and maintain the deployment

Follow the backup and recovery procedure before changing your deployment. To upload an encrypted relay snapshot every hour, follow Take hourly off-site snapshots. Recovery must preserve revoked access; replacing current databases with an older snapshot is not a supported rollback.

Stop the services without removing data:

node tools/self-host/bootstrap.mjs stop

Start them again and check readiness:

node tools/self-host/bootstrap.mjs start

Rotate the workspace secrets key

The server seals workspace secrets, such as API keys and webhook links, with DOHC_RELAY_LINK_KEY until you set DOHC_RELAY_SECRET_KEYS. DOHC_RELAY_SECRET_KEYS lists keys as id:key, separated by commas. An id is 1 to 32 lowercase letters, digits, and dashes. Each key needs at least 32 characters. The first key seals new secrets. Every listed key, and DOHC_RELAY_LINK_KEY, opens secrets sealed under it.

  1. Make a new key:

    openssl rand -hex 32
    
  2. Put it first in .env.self-host, and keep any key already listed after it:

    DOHC_RELAY_SECRET_KEYS=secrets-2026-12:NEW_KEY,secrets-2026-06:OLD_KEY
    
  3. Run node tools/self-host/bootstrap.mjs start. At startup the relay reseals every secret under the first key and logs a line like this:

    [sync-relay] workspace secrets on key secrets-2026-12: 12 resealed, 0 already current, 0 unreadable, 0 changed while resealing
    
  4. When the line shows 0 unreadable and 0 changed while resealing, every secret is on the new key. Remove the old key from the list. If some are unreadable, check that the older keys are listed exactly as before and restart.

Keep the old key until then. A secret whose key you remove stops working until its owner adds it again in Settings.

Upgrade the server

Each server release serves a range of relay API versions, and GET /ready on the relay reports it as apiVersions. A desktop newer than that range tells its user that the server runs an older version of dohc. Upgrade the server to serve that desktop again.

DOHC_RELAY_ENGINE_API_MIN in .env.self-host sets the oldest relay API version a desktop may sync with. It is 2 by default. A desktop older than that stops syncing and asks its user to update dohc. Its changes stay on that computer and sync once it is updated. Phones and share pages keep working. GET /ready reports the setting as engineApiMin.

The server writes and accepts notes in the newer format by default, and desktops that sync with it start new notes in it. Owners move their older notes over with Convert notes in Settings. Three settings control the format: DOHC_RELAY_BODY_SEQUENCE_NOTES, DOHC_ENGINE_NOTE_BODY_SEQUENCE and DOHC_ENGINE_NEW_NOTE_BODY_SEQUENCE. Each is on unless set to 0. Keep the first two on while the floor is 2, because desktops at version 2 convert notes to the newer format. To let a desktop older than version 2 sync for a while, set DOHC_RELAY_ENGINE_API_MIN=1 and restart.

Save an encrypted relay snapshot online while the deployment keeps running:

sudo install -d -o 1000 -g 1000 -m 0700 /srv/dohc-backups
node scripts/self-host/recovery.mjs snapshot /srv/dohc-backups/relay-before-upgrade

If you use the bundled Postgres database, also save an online database dump before upgrading:

(umask 077 && install -d -m 0700 /srv/dohc-backups && \
  docker compose --env-file .env.self-host -f docker-compose.self-host.yml exec -T postgres \
    sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB"' > /srv/dohc-backups/postgres-before-upgrade.sql.tmp && \
  mv /srv/dohc-backups/postgres-before-upgrade.sql.tmp /srv/dohc-backups/postgres-before-upgrade.sql)

An online snapshot covers offline file salvage, not an in-place relay restore. If you want a stopped continuity-matched backup and full volume archive instead, run bootstrap.mjs stop, recovery.mjs backup, and recovery.mjs archive before upgrading.

Update the Compose files and scripts (git pull in a repository checkout, or copy the new release bundle). Keep your .env.self-host, including DOHC_DEPLOYMENT_NAME, and all existing data volumes. Do not rerun init. Pull or load the new image, then upgrade in place (prefix with sudo if your gateway TLS files belong to root):

docker pull ghcr.io/dohchq/dohc-self-host:latest
node tools/self-host/bootstrap.mjs upgrade --image ghcr.io/dohchq/dohc-self-host:latest

If you built the image from source or pinned a specific tag, pass that image name instead.

The upgrade checks that the image is loaded, saves the previous configuration privately, updates DOHC_IMAGE, and runs the deployment check without stopping unchanged services. If the release changed a gateway Caddyfile, Cloudflare trust file, or app certificate (or on the first upgrade from a release before gateway config hashing), it recreates gateway first (a brief interruption on ports 80 and 443). Otherwise gateway and postgres keep running untouched. Database migrations run before the application containers recreate; if a release includes a schema change incompatible with the older API, sign-in can fail briefly until workspace-api finishes recreating. Compose then recreates only the services whose image or settings changed (workspace-api and sync-relay, then share-web). The gateway holds and retries incoming requests for up to 30 s while a backend restarts, and internal calls from share-web and workspace-api retry connection errors across the handover. Because sync-relay is a single SQLite writer, its restart or SQLite migration has a brief handover of a few seconds (or longer if a release builds an index over a large relay log). Live editing connections reconnect once the new relay listens. If the configuration has no DOHC_SHARE_WEB_SESSION_SEAL_KEY, the upgrade adds one. With it, open share pages go on working when the server restarts. If the upgrade fails, preserve the data and follow the recovery procedure.

Request logs

workspace-api, sync-relay and share-web each write one line per answered request: when it arrived, the method, the route and the status. For example: [share-web] request 2026-11-12T11:02:03.456Z GET /s/* 200. A line names the route's pattern, never the address that was requested, so link secrets, sign-in tokens and session ids stay out of it. It also omits the caller's IP address and every header. A path that matches no route logs as unmatched, a request to a published app as app, and the relay's service-to-service traffic as replication.

Docker keeps each service's newest lines up to a size (logging in docker-compose.self-host.yml): 50 MB for sync-relay, 20 MB for share-web and 10 MB for workspace-api. The sizes are chosen so a lightly used server keeps about a week of lines. Retention is by size, not age: a quieter server keeps lines for longer, and a busier one for less. The gateway writes no request lines; Docker keeps its newest 50 MB of other messages. Recreating a container deletes its lines. To keep more or less, change max-size and max-file there. The lines still show when each route was used, such as when a share link was opened, so keep them only as long as you need them.

Delete a server account

A signed-in person can preview deletion with POST /api/auth/account/deletion-preview. The preview lists the email, server origin, owned workspace IDs, stored bytes, and counts of shares and grants. It returns a preview token that expires after five minutes.

Send the token and account password as {"previewToken":"...","password":"..."} to POST /api/auth/account/delete. The preview returns passwordRequired: true. The server verifies the password before recording deletion and rate limits attempts like password sign-in. An incorrect or missing password refuses deletion, including for sessions created through device approval. If the preview changed, request another preview before continuing. Share-link and app credentials cannot delete a server account.

Deletion removes the server account, its owned workspaces, and their files, data, shares, apps, chats, and history. Local copies remain on each device. Received shares end, and their local copies remain readable. Contributions to another person's workspace stay in that workspace's history and discussion, including their stored authorship snapshots.

Deletion first blocks account access, then removes server data. If another service is unavailable, deletion stays pending and account sessions remain blocked. After the account-session fence commits, share links and server automation access can remain active until the relay receives its fence, especially during a relay outage. The server resumes pending deletion after a restart. The response reports finished: true only after the relay purge and account cleanup finish.

Account deletion does not edit backups. Backups keep the account's data until you delete them. Remove the person's email from DOHC_SIGN_UP_EMAILS yourself; the API does not change operator configuration. An empty list opens sign-up; keep at least one address if you want sign-up closed.

Disable a published app

If a published app is unsafe, run this command from the deployment bundle directory on the server:

docker compose --env-file .env.self-host -f docker-compose.self-host.yml exec -T sync-relay \
  node /app/services/sync-relay/dist/app-publication-takedown.js \
  --publication-id PUBLICATION_ID --reason "Phishing reported and confirmed"

Use the publication ID from the owner's publication list or the app URL's app parameter. The takedown worked when the command prints Disabled publication with that ID and exits with status 0. The command disables that one publication. The owner sees the reason and cannot reactivate that publication. The relay records the actor as "operator", the time, and the reason durably. It immediately refuses serving, new launches, and writes, including requests from existing launches.

The takedown also holds app publishing for the owner's account on this server. While the hold is on, the relay refuses every new publication and republication from that account. That includes the same app on a new share link, an edited copy, and the app in another workspace. The owner's other publications keep serving, including copies of the same app published before the takedown. The command lists the owner's other active publications of the same app, such as the app on another share link or in another workspace. Disable each of those by its own publication ID. An edited copy has a different bundle, so the list leaves it out. The list shows up to 50 publications. Run the same takedown again to list the rest. The hold belongs to the account. Deleting the account removes it.

To lift the hold, run the same command with --lift-hold instead of --reason. Any publication taken down since the last lift identifies the hold:

docker compose --env-file .env.self-host -f docker-compose.self-host.yml exec -T sync-relay \
  node /app/services/sync-relay/dist/app-publication-takedown.js \
  --publication-id PUBLICATION_ID --lift-hold

The owner can then publish apps again. The disabled publication stays disabled.

The command uses a private socket inside the running relay container. Other publications, sync, and sharing keep running. Use Compose's --env-file, -f, or --project-name options when selecting a custom deployment. Exit codes are 0 for success, 2 for bad input, 3 for not found, and 1 for connection or operation failures. The operator socket requires a secret from /continuity/publication-operator.secret, beside the deployment configuration. The relay creates this file with mode 0600. The takedown command reads it automatically. Run the command with access to the continuity volume.

The client times out after 10 seconds. Retries preserve the first takedown record. A retry after a lift holds the owner's app publishing again.

Restoring a backup taken before the takedown brings that publication back and removes the hold. Run the takedown command again after restoring such a backup.