Self-host AFFiNE with Levelrail

A block-based workspace combining docs, whiteboards, and databases in one self-hosted app.

  • Memory1 GiB
  • Archarm64
  • Services3

How to self-host AFFiNE

  1. Pull the images

    3 images are pulled on your server.

    Show images
    • ghcr.io/toeverything/affine:stable
    • pgvector/pgvector:pg16
    • redis:7-alpine
  2. Create the app

    3 services start in a single Compose app, with 4 named volume mounts for your data, on port 3010.

  3. Fill in the secrets

    2 secrets are generated and stored encrypted, 7 settings are preset, you do not have to fill in anything.

  4. Open it

    Without a domain the app gets an sslip.io address; add --domain SERVICE=HOST to use your own.

AFFiNE requirements

Memory
About 1 GiB
Architectures
amd64 image published, arm64 image published
Ports
3010
Domain
Optional, an sslip.io address is used without one
Settings
none to fill in
License
not yet recorded
  • Listed. It is in the catalog but not verified. Back up the data volume before changing an image tag.
  • Host ports. It publishes port 3010 on the host, so open them in the VPS firewall only if you want that.

Install Levelrail first

On a server with Levelrail running, run the command above, or open the dashboard: Apps, New app, Browse templates, then AFFiNE. New to Levelrail? Install it on a fresh VPS first.

docker pull ghcr.io/glincker/levelrail:latest

Then levelrail-cli login --device. See Getting started and the AFFiNE docs page.

Deploy AFFiNE your way

Every format below deploys the same pinned images. Pick the one that fits how you work.

Deploy AFFiNE from the CLI

levelrail-cli templates deploy affine --name my-affine

Deploy AFFiNE with the API

Create a token in the dashboard first. This one-click route deploys it as a trial app you can keep or remove.

curl -X POST -H "Authorization: Bearer $TOKEN" \
  https://levelrail.example.com/api/v1/service-templates/affine/deploy

AFFiNE configuration

AFFiNE services

ServiceImagePortsVolumes
affine ghcr.io/toeverything/affine:stable 3010 affine_storage -> /root/.affine/storageaffine_config -> /root/.affine/config
db pgvector/pgvector:pg16 none affine_db_data -> /var/lib/postgresql/data
redis redis:7-alpine none affine_redis_data -> /data

AFFiNE environment variables

VariableServiceValue
AFFINE_SERVER_HOST affine Preset by the template
AFFINE_SERVER_HTTPS affine Preset by the template
AFFINE_SERVER_PORT affine Preset by the template
DATABASE_URL affine Generated at deploy
NODE_ENV affine Preset by the template
REDIS_SERVER_HOST affine Preset by the template
POSTGRES_DB db Preset by the template
POSTGRES_PASSWORD db Generated at deploy
Show all 9 variables
  • POSTGRES_USERdbPreset by the template

Ports and volumes

Ports
3010
Volumes
4 named mounts: affine_storage -> /root/.affine/storage, affine_config -> /root/.affine/config, affine_db_data -> /var/lib/postgresql/data, affine_redis_data -> /data

AFFiNE FAQ

How much memory does AFFiNE need?

The catalog lists about 1 GiB of memory for AFFiNE across its 3 services.

Does AFFiNE run on arm64?

For AFFiNE, an arm64 image is published; amd64 is image published.

Does AFFiNE need configuration before it starts?

No. The template fills in its own defaults and generates secrets at deploy time.

Which database does AFFiNE bundle?

The template includes Redis, running as its own service.

Which ports does AFFiNE use?

AFFiNE listens on port 3010 inside the stack.

Where does AFFiNE keep its data?

In named volumes: affine_storage mounted at /root/.affine/storage, affine_config mounted at /root/.affine/config, affine_db_data mounted at /var/lib/postgresql/data and affine_redis_data mounted at /data.

Can I deploy AFFiNE on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for AFFiNE, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image ghcr.io/toeverything/affine:stable, pgvector/pgvector:pg16, redis:7-alpine is what you deploy there.

levelrail-cli templates deploy affine --name my-affine