AFFiNE logo

AFFiNE

Write, Draw and Plan All at Once

Alternative to: notion, miro


A privacy-focused, local-first, open-source, and ready-to-use alternative for Notion and Miro. One hyper-fused platform for wildly creative minds.

AFFiNE Docker Compose example

Self-host AFFiNE on your own server, homelab, or VPS starting from this Docker Compose example. It runs AFFiNE in Docker containers using the official ghcr.io/toeverything/affine:stable, ghcr.io/toeverything/affine:stable, redis, pgvector/pgvector:pg16 images, with persistent volumes and automatic restarts preconfigured. Review the environment variables and adjust them to your setup, save the file as compose.yml (or docker-compose.yml), and start the stack with docker compose up -d.

services:
  affine:
    image: ghcr.io/toeverything/affine:stable
    depends_on:
      redis:
        condition: service_healthy
      postgres:
        condition: service_healthy
      affine_migration:
        condition: service_completed_successfully
    volumes:
      - uploads:/root/.affine/storage
      - config:/root/.affine/config
    environment:
      - REDIS_SERVER_HOST=redis
      - DATABASE_URL=postgresql://affine:@postgres:5432/affine
      - AFFINE_INDEXER_ENABLED=false
      - AFFINE_SERVER_EXTERNAL_URL=http://localhost:3010
      - DB_USERNAME=affine
      - DB_PASSWORD=
      - DB_DATABASE=affine
    restart: unless-stopped

  affine_migration:
    image: ghcr.io/toeverything/affine:stable
    volumes:
      - uploads:/root/.affine/storage
      - config:/root/.affine/config
    command: ['sh', '-c', 'node ./scripts/self-host-predeploy.js']
    environment:
      - REDIS_SERVER_HOST=redis
      - DATABASE_URL=postgresql://affine:@postgres:5432/affine
      - AFFINE_INDEXER_ENABLED=false
      - AFFINE_SERVER_EXTERNAL_URL=http://localhost:3010
      - DB_USERNAME=affine
      - DB_PASSWORD=
      - DB_DATABASE=affine
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  redis:
    image: redis
    healthcheck:
      test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping']
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

  postgres:
    image: pgvector/pgvector:pg16
    volumes:
      - db_data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: affine
      POSTGRES_PASSWORD: 
      POSTGRES_DB: affine
      POSTGRES_INITDB_ARGS: '--data-checksums'
      # you better set a password for you database
      # or you may add 'POSTGRES_HOST_AUTH_METHOD=trust' to ignore postgres security policy
      POSTGRES_HOST_AUTH_METHOD: trust
    healthcheck:
      test:
        ['CMD', 'pg_isready', '-U', "affine", '-d', "affine"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  uploads:
  config:
  db_data:

Prefer a managed setup? WinterFlow installs, configures, and updates AFFiNE for you using this same Docker Compose configuration.