Installing the servers¶
This page is the complete checklist for a Sparrow network: what you need before you start, every setting of every server, the Firebase setup for phone verification, and how the app gets the network's address. The three ways to install (installer window, terminal, Coolify) are described at the end; Coolify deployment has the click-by-click details for Coolify.
The servers and how they trust each other¶
| Server | What it does | How many |
|---|---|---|
| Directory | Signed list of the Control Planes; phone verification for all of them. Run by the network's operator. | one for the whole network |
| Control Plane | Node registry (signed node directory) and presence directory (alias claims, invitation routes). | one or more |
| Community Node | Mailboxes, circuit relay (gateway), federation, encrypted attachment blobs, exchange rates and link previews. | one or more, ideally run by different people |
Install them in this order, because each one needs the one before:
- Directory. It creates its signing key once. Apps and servers pin that key on first contact; it can never change without every app noticing, so back it up (see Backups).
- Control Plane. It pins the Directory key, registers itself at the Directory (automatically, after the Directory checked its HTTPS endpoint and key) and creates its own root identity once.
- Community Node. It registers at a Control Plane, which publishes it in the signed node directory.
- App. It is built with the Directory URL; everything else it finds through the Directory.
1. Before you start¶
Servers¶
| Directory | Control Plane + Community Node (Combined, one machine) | |
|---|---|---|
| Runs | Python service + phone verifier + Caddy | five Java services, PostgreSQL ×2, Redis, Caddy |
| Memory | a few hundred MB | 4 GB at least, 8 GB recommended (each Java service is capped at 512 MB heap) |
| Swap | recommended | required: 8 GB (see below) |
| Disk | 1 GB | 20 GB plus the blob storage (BLOB_MAXIMUM_STORAGE_BYTES, default 10 GiB) |
| CPU | 1 vCPU | 2 vCPU |
The Directory can run on the same machine as a Control Plane. Building the images yourself (Coolify, or Build from source in the installer) needs about 2 GB more memory while the build runs.
Add swap on every Linux VPS before the first installation; many VPS images have none, and without it the kernel kills services as soon as a build and the running services need more memory than the machine has:
fallocate -l 8G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
Software¶
- Installer window / terminal: Docker Engine with Compose v2 (Linux) or Docker Desktop (Windows, macOS), and
Python 3.9+. The window also needs Tk (
python3-tkon most Linux desktops); over SSH the installer shows a text menu instead. Signed Directory lookups for added nodes need the Python packagecryptography. - Coolify: only Coolify itself (it brings Docker). See Coolify deployment.
Network¶
- A public IPv4 address for every public server, with TCP 80 and 443 reachable (443/UDP optional for HTTP/3). Behind a router: forward these ports to the machine. Firewall: allow 22 (SSH), 80 and 443, nothing else; diagnostic ports stay on localhost.
- Nothing else may use ports 80/443 on that machine: the installer's Caddy and Coolify's proxy both need them. Use one way of installing per machine.
- One name per server, pointing to its machine: your own DNS
Arecords (for exampledirectory.example.com,control.example.com,node.example.com), or the free automatic sslip.io names that need no DNS (directory-203-0-113-10.sslip.io, which change when the IP changes). HTTPS certificates come from Let's Encrypt automatically. - LAN installations (testing without public addresses) work with the installer's LAN mode. Apps reach them only inside that network.
Accounts and files to have ready¶
| What | Needed for | Where it comes from |
|---|---|---|
| Firebase project with phone sign-in | phone verification at sign-up | section 3 |
| Firebase Admin service account JSON | the Directory's phone verifier | Firebase console, section 3 |
| Operator name | Community Nodes | your choice, the same on all your nodes |
| Test phone numbers (optional) | testers who reinstall often | your test devices |
Without phone verification (PHONE_VERIFICATION_REQUIRED=false on Coolify, the box unticked in the Directory
installer) everything works except binding real phone numbers: only test numbers can then be found by others.
2. Settings of each server¶
In the installer most settings are fields in the window and the rest are written to the server folder
(control-plane/.env.runtime, community-node/.env.runtime, sparrow.conf); change those only through the
installer and apply them with Start / apply settings. On Coolify they are the resource's Environment
Variables. Passwords are always generated (installer: secrets/; Coolify: SERVICE_PASSWORD_*); never set them
by hand.
Directory¶
| Setting | Default | Installer | Meaning |
|---|---|---|---|
| Hostname | directory-<ip>.sslip.io |
Hostname (Automatic) / --hostname |
public name of the Directory; Coolify: the domain on directory-caddy |
| HTTPS proxy | shared if a Sparrow server runs here | HTTPS proxy / --standalone, --server-folder |
share the Caddy of a Sparrow server on the same machine, or run an own Caddy on 80/443 |
PHONE_VERIFICATION_REQUIRED |
true |
Verify phone numbers for all Control Planes / --phone-verification, --no-phone-verification |
phone verification on; with true and no valid Firebase file the phone verifier stops (unhealthy) |
FIREBASE_ADMIN_JSON |
– | Firebase Admin file / --firebase-admin-file <file> |
Firebase Admin service account JSON of the app's Firebase project; only the phone verifier receives it, kept in memory (Coolify) or mounted read-only from private/firebase-admin.json (installer) |
PHONE_VERIFICATIONS_PER_DAY |
10 |
Verifications per day / --phone-verifications-per-day N |
sign-ups per UTC day for the whole network; 0 = no limit. A full day sends no SMS |
PHONE_VERIFICATION_RESENDS |
1 |
Resends / --phone-verification-resends N |
how often the app may send the code again per sign-up |
The Directory publishes its URL and public key in the window (Copy) and at /.well-known/sparrow-directory.
Its administrator interface listens only inside the container and is never published.
Control Plane¶
| Setting | Default | Installer | Meaning |
|---|---|---|---|
| Hostname | control-<ip>.sslip.io |
automatic hostnames / --auto-dns, --control-domain |
public name; Coolify: the domain on caddy (SERVICE_FQDN_CADDY) |
CONTROL_PLANE_DIRECTORY_URL |
– | Directory Server URL / --directory-url (saved in sparrow.conf) |
the Directory this Control Plane registers at and whose key it pins |
CONTROL_PLANE_DIRECTORY_PUBLIC_KEY |
pinned on first use (Coolify) | sparrow.conf, or built into the bundle |
the Directory's public key (unpadded base64url). Coolify pins it on first use only if the Directory's signed list verifies with it; set it only to pin a known key. Never take it from the Directory you want to verify by hand |
PRESENCE_TEST_PHONE_NUMBERS (Coolify) / PRESENCE_TEST_PHONE_ALIASES (installer) |
– | Test phone numbers | test numbers with country code, comma-separated (+15550000001,+15550000002). They sign up without SMS and move to the device that registers them last. Only their phone aliases are stored. Never enter real users' numbers |
NODE_REGISTRY_REGISTRATION_RATE_LIMIT_REQUESTS / …_WINDOW_MILLISECONDS |
30 per 3600000 (1 h) |
.env.runtime |
node registrations per client and window |
NODE_REGISTRY_HEARTBEAT_RATE_LIMIT_REQUESTS / …_WINDOW_MILLISECONDS |
180 per 60000 (1 min) |
.env.runtime |
node heartbeats per client and window |
NODE_REGISTRY_HEARTBEAT_GRACE_MILLISECONDS |
5000 (compose) |
.env.runtime |
how late a node's heartbeat may be before it drops out of the node directory |
NODE_REGISTRY_RATE_LIMIT_MAXIMUM_TRACKED_CLIENTS |
100000 |
.env.runtime |
memory bound of the rate limiter |
Community Node¶
| Setting | Default | Installer | Meaning |
|---|---|---|---|
| Hostname | node-<ip>.sslip.io |
automatic hostnames / --auto-dns, --node-domain |
public name; Coolify: the domain on caddy |
CONTROL_PLANE_URL |
the Combined Control Plane | Control Plane URL (Nodes… → Add) / --control-plane-url |
the Control Plane this node registers at. Required on Coolify and for Community Node only |
CONTROL_PLANE_DIRECTORY_URL |
– | Directory Server URL / nodes configure-directory --directory-url |
the Directory whose Control Plane list the node keeps current (directory-sync); empty = only CONTROL_PLANE_URL |
CONTROL_PLANE_DIRECTORY_PUBLIC_KEY |
pinned on first use (Coolify) | --directory-public-key |
as for the Control Plane |
NODE_OPERATOR |
– (the node is its own operator) | Operator name | who runs the node, signed into its descriptor. Use the same name on all your nodes: apps never put two nodes of one operator into a circuit |
MAILBOX_MAXIMUM_MAILBOXES |
100000 |
.env.runtime |
mailboxes this node holds at most |
MAILBOX_CREATION_WORK_BITS |
18 |
.env.runtime |
proof of work an app must do to create a mailbox |
BLOB_MAXIMUM_BYTES |
134217728 (128 MiB) |
.env.runtime |
largest encrypted attachment |
BLOB_MAXIMUM_STORAGE_BYTES |
10737418240 (10 GiB) |
.env.runtime |
all attachments together; plan the disk for it |
EXCHANGE_RATES_URL |
Frankfurter (https://api.frankfurter.dev/v2/rates?base=EUR) |
.env.runtime |
where the node fetches exchange rates for group expenses once a day; the provider sees only the node's address |
RELAY_PRIVATE_DESTINATIONS |
false (LAN mode: true) |
set by the mode | lets relays reach private addresses; only for LAN installations |
Set by the installer, never by hand: CLIENT_ENDPOINT, MAILBOX_ENDPOINT, CONTROL_PLANE_URLS,
ADVERTISED_CONTROL_PLANE_URLS, MANUAL_CONTROL_PLANE_URLS, LOCAL_CONTROL_PLANE_DOMAIN, the
*_PROJECT_NAME, *_BIND_ADDRESS, *_HTTP_PORT, *_SITE_ADDRESS, *_DIAGNOSTIC_PORT and database/Redis ports,
COMMUNITY_NODE_DIRECTORY_CACHE_VOLUME, and all *_PASSWORD / *_PASSWORD_FILE values. On Coolify the Compose
files derive them from the domain.
All Java services¶
JAVA_TOOL_OPTIONS (default -Xmx512m -XX:MaxMetaspaceSize=192m -XX:+UseSerialGC, from server/Dockerfile)
caps each service's memory. Set it on a single service (Coolify: that service's variables) to give it more.
3. Firebase phone verification¶
Phone numbers are verified once at sign-up by SMS through Firebase. Only the Directory's phone verifier checks the result; Control Planes and Community Nodes need no Firebase at all. Set it up once for the network:
- Project. In the Firebase console create a project (or use the existing one). Phone sign-in needs the Blaze (pay as you go) plan.
- Phone sign-in. Authentication → Sign-in method → enable Phone.
- Android app. Project settings → Add app → Android, package name
com.cbgm.sparrow. Add the SHA-1 and SHA-256 fingerprints of every key the app is signed with (release keystore, and the debug key for local builds:keytool -list -v -keystore <keystore>). Nogoogle-services.jsonis needed. - App values. From Project settings → your Android app take the App ID, the Web API key and the project ID.
They go into the app build:
FIREBASE_APP_ID,FIREBASE_API_KEY,FIREBASE_PROJECT_ID(see section 4). - Service account for the Directory. Project settings → Service accounts → Generate new private key.
Give that JSON file to the Directory (installer: Firebase Admin file; Coolify:
FIREBASE_ADMIN_JSON, multiline and locked). Never commit it. - SMS regions. Authentication → Settings → SMS region policy: allow the countries of your users, or deny the expensive ones. New projects allow none until one is set.
- Cost limit. Google Cloud console → Billing → Budgets & alerts: set a budget and connect the function that
turns billing off when it is reached. The first SMS each day are free; beyond that the price depends on the
country. Keep
PHONE_VERIFICATIONS_PER_DAYin line with the budget. - App check. While the app is not installed from the Play Store, Firebase checks each SMS request with
reCAPTCHA, which needs the API key usable for
<project-id>.firebaseapp.com: do not restrict the key to the Android app yet. Once the app comes from the Play Store, restrict the key and turn on App Check with Play Integrity. - Test numbers (optional). Authentication → Sign-in method → Phone → Phone numbers for testing: add the
numbers with a fixed code. Enter the same numbers on the Control Plane (
PRESENCE_TEST_PHONE_NUMBERS/ Test phone numbers) so they can be bound without SMS.
More on costs and limits: server/control-plane-directory/README-INSTALL.md ("Phone verification",
"Firebase costs").
4. The app¶
The app only needs the Directory URL and the Firebase values; it finds Control Planes and nodes through the Directory and pins its key on first start.
- Local builds: in the repository's
local.properties(see Local development):
CONTROL_PLANE_DIRECTORY_URL=https://directory.example.com
CONTROL_PLANE_RELEASE_DIRECTORY_URL=https://directory.example.com
FIREBASE_APP_ID=1:...:android:...
FIREBASE_API_KEY=AIza...
FIREBASE_PROJECT_ID=<project-id>
- Release builds (GitHub Actions): repository Variables
CONTROL_PLANE_DIRECTORY_URL,CONTROL_PLANE_RELEASE_DIRECTORY_URL,FIREBASE_APP_ID,FIREBASE_API_KEY,FIREBASE_PROJECT_ID, and the signing Secrets (see Release process).
Users can change the Directory URL later in Settings → Network; a moved Directory must present the same key.
5. Ways to install¶
Each server can be installed in three ways. All three run the same server code and the same Caddy routes; they differ only in who starts the containers and who owns HTTPS.
| Installer window | Terminal (SSH) | Coolify | |
|---|---|---|---|
| Who starts the containers | the installer, on this computer | the installer, without a desktop | Coolify, from the Git repository |
| HTTPS | the installer's Caddy on ports 80/443 | the installer's Caddy on ports 80/443 | Coolify's proxy on ports 80/443 |
| Updates | Updates card / Start | install / update commands |
Coolify Auto Deploy on push / version tag |
| Compose files | docker-compose.yml + overlays |
docker-compose.yml + overlays |
docker-compose.coolify.yml |
| Directory | Start-SparrowDirectory.* |
Start-SparrowDirectory.sh install … |
server/control-plane-directory/docker-compose.coolify.yml |
| Control Plane + Community Node | Start-SparrowServer.* (Combined) |
Start-SparrowServer.sh install … |
one Coolify resource each |
One way per computer
The installer and Coolify both need ports 80 and 443. Do not run the installer on a computer that runs Coolify, and do not install the same server twice with two ways. Moving a server from one way to another means a new installation (or copying its Docker volumes, see the Coolify guide).
Installer window¶
The window runs on Windows, macOS and Linux with a desktop.
Directory (first). Start Start-SparrowDirectory.cmd (Windows), .command (macOS) or ./Start-SparrowDirectory.sh
(Linux) from server/control-plane-directory of a source checkout; it first asks for a new folder for the
Directory. Choose the hostname and the HTTPS proxy, tick Verify phone numbers for all Control Planes, choose
the Firebase Admin file, set Verifications per day and Resends, and click Install / Start. Copy the
Directory URL shown in the window.
Control Plane + Community Node. Unpack sparrow-server-<version>-<os>.zip from the GitHub release into a new
folder, or start server/installer/Start-SparrowServer.* from a source checkout (it asks for a new server folder,
default ~/Sparrow Server). Under What to install choose Combined, choose Public with automatic sslip.io
names or your own domains, paste the Directory Server URL, enter the Operator name and, if you want, the
Test phone numbers, and click Install. If the Directory runs on the same machine, install this server first
and then the Directory with the shared proxy.
More nodes. Nodes... → Add...: name, Public or LAN, hostname, Control Plane URL (empty = this installation's), then Install. On a machine that only runs nodes for another operator's Control Plane, choose Community Node only. Every node gets its own identity, database and volumes.
Details: server/installer/README.md, server/installer/README_RUNTIME.md,
server/control-plane-directory/README-INSTALL.md.
Terminal (SSH, no desktop)¶
The same installers run without a desktop: started without arguments over SSH they show a text menu, and every
action is also a command. Example for a VPS with the (fictional) address 203.0.113.10:
# 1. Directory with its own proxy and phone verification
cd ~/Sparrow/server/control-plane-directory
./Start-SparrowDirectory.sh install --standalone \
--phone-verification --firebase-admin-file ~/firebase-admin.json \
--phone-verifications-per-day 10 --phone-verification-resends 1
./Start-SparrowDirectory.sh status
# 2. Control Plane + Community Node, Public with automatic sslip.io names
cd ~/Sparrow/server/installer
./Start-SparrowServer.sh install --component combined --mode public --auto-dns \
--directory-url https://directory-203-0-113-10.sslip.io
# … or with your own domains
./Start-SparrowServer.sh install --component combined --mode public \
--node-domain node.example.com --control-domain control.example.com \
--directory-url https://directory.example.com
./Start-SparrowServer.sh status --component combined
# 3. More nodes (for example for another Control Plane)
./Start-SparrowServer.sh nodes add --name "Node A" --mode public --auto-dns \
--control-plane-url https://control.example.com
./Start-SparrowServer.sh nodes install --id <node-id>
The operator name and the test numbers are set in the text menu (Operator name, Test phone numbers) and applied with start.
If the Directory runs on the same machine as the Control Plane, install the server first and then the Directory
without --standalone. All commands: ./Start-SparrowServer.sh --help, ./Start-SparrowServer.sh nodes --help,
./Start-SparrowDirectory.sh --help.
Coolify¶
Coolify builds the three servers from the Git repository and deploys them with its own Auto Deploy: the
develop environment on every push to develop or a branch made from it that changes a server, the
production environment on every version tag. The settings of section 2 are the
resources' environment variables. Step by step: Coolify deployment.
6. After the installation¶
Check the chain once, in this order:
https://<directory>/healthanswers, andhttps://<directory>/v1/control-planeslists the Control Plane.https://<control-plane>/health/registryand/health/presenceanswer with HTTP 200.https://<control-plane>/v1/nodeslists the Community Node.https://<node>/health/gateway,/health/federationand/health/mailboxanswer with HTTP 200.- A freshly built app signs up with a phone number (or a test number), and two apps can exchange messages.
The Control Plane and the Community Node also have an overview page at /index with these links.
Backups¶
Back up before every update; image updates may run database migrations that are not undone. What cannot be recreated:
- Directory: its signing key and registrations (installer: Docker volume
sparrow-central-directory-state; Coolify:directory-state) and the phone verifier's keys (sparrow-phone-verifier-state/phone-verifier-state). Apps pin the Directory key: a lost key means every app has to be pointed at a new Directory. - Control Plane: its root identity (installer:
control-plane/secrets/registry-root.identity; Coolify:registry-identity,registry-authority). The Directory and the nodes trust it. - Community Node: its identity (
node-identity), the mailbox database and the blob storage.
How to copy a volume: Coolify deployment. Never delete these volumes to troubleshoot.
Updates¶
- Installer: Updates card (latest release, ZIP or source) or
./Start-SparrowServer.sh update --release; the Directory with Update from source... /./Start-SparrowDirectory.sh update --source ~/Sparrow. Identities, databases and settings are kept. - Coolify: a new version tag deploys production; see Coolify deployment.
See also Docker & Troubleshooting and Secrets.