top of page

Selfhost AFFiNE on Unraid using docker

Updated: Mar 10

Hello ! A few weeks ago I published a post that explained how to host Monica on Unraid using docker-compose.


So I'm assuming you have already installed the "Docker Compose" plugin on your Unraid server and that you know how to use it. If this is not the case, I will redirect you to this article:


Today I will quickly share with you how to selfhost AFFiNE on Unraid using docker.


But first, what is AFFiNE?

According to their GitHub page, AFFiNE is a sort of cross between Notion and Miro, offering an open-source, all-in-one platform designed to merge writing, drawing, and planning into a hyper-fused, privacy-oriented workspace and local-first. With its limitless canvas for all types of blocks — rich text, notes, embedded web pages, and more. AFFiNE positions itself as the ultimate solution for creative minds. The platform supports real-time collaboration, offers the possibility of self-management and self-hosting, and prepares the arrival of a community of plugins for advanced customization. AFFiNE is the perfect tool for those looking to push the boundaries of their productivity and creativity.


⚠️ Disclaimer: They're the ones who say it, not me. I just tried to gather the information.




Basically, you take Notion, you take Miro, and you merge them. That's it, I'm the one who says it.


Install AFFiNE

So let's get to the heart of the matter, to install AFFiNE I modified a little bit their compose.yaml file which is available on their github .


So here is my version and I have annotated some comments so that you can complete it more easily on your side.


🆕 To make it easier to copy/paste/download this code, I've created a repository dedicated to my blog's resources on github. Here's the link to the docker-compose.yml file for this article:


services:
  affine:
    image: ghcr.io/toeverything/affine-graphql:stable
    container_name: affine_selfhosted
    command:
      ['sh', '-c', 'node ./scripts/self-host-predeploy && node ./dist/index.js']
    ports:
    # CHANGE YOUR PORTS HERE IF NEEDED PORT:PORT_INSIDE_CONTAINER
      - '3010:3010'
      - '5555:5555'
    depends_on:
      redis:
        condition: service_healthy
      postgres:
        condition: service_healthy
    volumes:
      # CHANGE YOUR PATH HERE FOR the custom configuration
      - /mnt/user/appdata/affine-app:/root/.affine/config
      # CHANGE YOUR PATH HERE FOR blob storage
      - /mnt/user/appdata/affine-app:/root/.affine/storage
    logging:
      driver: 'json-file'
      options:
        max-size: '1000m'
    restart: unless-stopped
    environment:
      - NODE_OPTIONS="--import=./scripts/register.js"
      - AFFINE_CONFIG_PATH=/root/.affine/config
      - REDIS_SERVER_HOST=redis
      # REPLACE MY_DB_PWD_TOP_SECRET BY YOUR PWD
	- DATABASE_URL=postgres://affine:MY_DB_PWD_TOP_SECRET@postgres:5432/affine
      - NODE_ENV=production
      # REPLACE YOUR_EMAIL BY YOUR EMAIL
      - AFFINE_ADMIN_EMAIL=YOUR_EMAIL
      # REPLACE YOUR_PWD BY YOUR PWD
      - AFFINE_ADMIN_PASSWORD=YOUR_PWD
  redis:
    image: redis
    container_name: affine_redis
    restart: unless-stopped
    volumes:
    # CHANGE YOUR PATH HERE
      - /mnt/user/appdata/affine-redis:/data
    healthcheck:
      test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping']
      interval: 10s
      timeout: 5s
      retries: 5
  postgres:
    image: postgres
    container_name: affine_postgres
    restart: unless-stopped
    volumes:
    # CHANGE YOUR PATH HERE
      - /mnt/user/appdata/affine-db:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U affine']
      interval: 10s
      timeout: 5s
      retries: 5
    environment:
      POSTGRES_USER: affine
      # REPLACE MY_DB_PWD_TOP_SECRET BY YOUR PWD
      POSTGRES_PASSWORD: MY_DB_PWD_TOP_SECRET
      POSTGRES_DB: affine
      PGDATA: /var/lib/postgresql/data/pgdata

Of course you can also make other changes if you want, like changing the postgres username or that sort of thing.


For installation, nothing could be simpler => Unraid > Docker > New Stack > Edit Stack > We add the content of our compose.yaml file and that's it => Compose Up, and it works!


Config in the app

As mentioned in the official documentation , don't forget to log in with your credentials and then synchronize your workspace with the "cloud". By cloud they mean "your own server" since we are on selfhost.



These are the credentials that you specified in the compose.yaml file



Once logged in, all you have to do is synchronize the workspace with “the cloud” (which is in fact your own server) .


There you go, Enjoy! 😎


AlexIn Tech

44 views

Comentarios


bottom of page