Peergos is an end-to-end encrypted storage platform with a web UI, a CLI, FUSE and WebDAV clients, and peer-to-peer data transfer between instances. This post documents how the instance can be deployed via docker-compose.
Beware that you don’t have to selfhost. Peergos is zero trust and your identity is not bound to a specific server (you just choose a homeserver). There is awesome hosting at https://peergos.org/pricing
Motivation
I’ve always been hosting my data myself on my own hardware. I started with Seafile and switched to Nextcloud at some point.
There were two major aspects which bothered me with Nextcloud:
- End-to-end encryption (E2EE) is not a first class citizen, has a lot of limitations and I don’t think it is considered production-ready
- I not only host for myself but also for my family and my friends. I like providing that service but I very much dislike them being dependent on me
Why Peergos is better in these regards:
- E2EE is a first-class citizen, the server has not to be trusted; this is a benefit for the server operator as well as the users
- With peergos you choose a homeserver but you can easily migrate to another homeserver and keep your identity (portable identity); this would allow my friends and family to move away from my server without any major troubles
See https://book.peergos.org/ for more perks.
Deployment
DNS and TLS
Peergos is reachable at https://peergos.example.com. The routing setup also serves *.peergos.example.com, so two DNS records are required:
peergos.example.com(A/AAAA)*.peergos.example.com(A/AAAA)
Traefik terminates TLS and obtains a wildcard certificate through its Let’s Encrypt DNS challenge. The Peergos container joins a dedicated external Docker network, and Traefik joins the same network:
labels:
- traefik.enable=true
- traefik.docker.network=peergos-external
- 'traefik.http.routers.peergos.rule=Host(`peergos.example.com`) || HostRegexp(`^.+\.peergos\.example\.com$$`)'
- traefik.http.routers.peergos.entrypoints=websecure
- traefik.http.routers.peergos.service=peergos
- traefik.http.routers.peergos.tls=true
- traefik.http.routers.peergos.tls.certresolver=letsencrypt
- traefik.http.routers.peergos.tls.domains[0].main=peergos.example.com
- "traefik.http.routers.peergos.tls.domains[0].sans=*.peergos.example.com"
- traefik.http.services.peergos.loadbalancer.server.port=8000
The container itself only exposes port 8000 on the Docker network. Port 8000 is never published to the host.
Firewall
Peergos uses port 4001 for peer-to-peer traffic, both TCP and UDP (QUIC). Configure your host firewall accordingly.
For NixOS this looks as follows:
networking.firewall.allowedTCPPorts = [
4001 # peergos p2p
];
networking.firewall.allowedUDPPorts = [
4001 # peergos p2p quic
];
The container
The stack lives in peergos/docker-compose.yml. The current version is:
services:
peergos:
image: ghcr.io/peergos/web-ui:v1.43.0@sha256:a3eab51b275f27a212567dcc621651e5738ed8795f683e49d4fcaac754f5ddf8
container_name: peergos
restart: unless-stopped
command:
- daemon
- -listen-host
- 0.0.0.0
- -public-domain
- peergos.example.com
- -public-server
- "true"
- -generate-token
- "false"
- -quota-upload-limit-seconds
- "600"
- -log-to-console
- "true"
environment:
- JAVA_TOOL_OPTIONS=-Xms1g -Xmx4g
volumes:
# sqlite DBs, config, address book, etc.
- /appdata-ssd/peergos-data:/opt/peergos/data
# blockstore
- /appdata-hdd/peergos-blocks:/opt/peergos/data/.ipfs/blocks
expose:
- 8000
ports:
- "4001:4001/tcp"
- "4001:4001/udp"
stop_grace_period: 1m
networks:
- peergos-external
mem_limit: 6g
memswap_limit: 8g
# Signups are disabled. To allow exactly one signup, create a single-use token:
# docker exec peergos /opt/peergos/docker-entrypoint.sh quota token create
networks:
peergos-external:
external: true
The split between SSD and HDD is deliberate: SQLite databases, configuration and the address book live on the SSD, while the blockstore lives on the HDD. Peergos is a JVM application, so the container gets a 1–4 GB heap and a 6 GB memory limit with an 8 GB swap limit.
Creating the first account
Signups are disabled with -generate-token false. To allow exactly one signup, create a single-use token inside the running container:
docker exec peergos /opt/peergos/docker-entrypoint.sh quota token create
Then register the account with that token in the web UI. To increase the users quota call e.g.
docker exec peergos /opt/peergos/docker-entrypoint.sh quota set -username USERNAME -quota 150g
Client-side
The desktop client
The desktop Peergos client on the laptop is a Flatpak. Its WebDAV mount needs gvfs and gio from the host, which are not part of the Flatpak sandbox. The following NixOS configuration installs glib system-wide and enables the GVFS service:
environment.systemPackages = with pkgs; [
glib # gio, needed by flatpak-spawn --host (Peergos WebDAV mount)
];
services.gvfs.enable = true;
Adding gvfs to the user’s Home Manager packages was not enough; it has to be available system-wide for the Flatpak-spawned host process.
Mounting
The desktop client mounts via webdav which is also recommended as a “cli-way”.
For me the fuse mount with peergos fuse was capped at about 0,5MiB/s. With webdav I get between 10 and 30 MiB/s in a local network.