跳至主要內容

AFFINE-团队协作Notion替代品

程序员李某某大约 2 分钟

AFFINE-团队协作Notion替代品

简介

本地部署

## 克隆源码 --- stable 是稳定版本
git clone https://github.com/toeverything/AFFiNE.git --branch stable
cd AFFiNE
## 修改配置
vim .github/deployment/self-host/compose.yaml

#######

compose.yaml

services:
  affine:
    ################## 没有魔法就换一下地址
    # image: ghcr.nju.edu.cn/toeverything/affine-graphql:stable
    image: ghcr.io/toeverything/affine-graphql:stable
    container_name: affine_selfhosted
    command:
      ['sh', '-c', 'node ./scripts/self-host-predeploy && node ./dist/index.js']
    ports:
      - '3010:3010'
      - '5555:5555'
    depends_on:
      redis:
        condition: service_healthy
      postgres:
        condition: service_healthy
    volumes:
      ################ 这个挂载出来的文件留意一下,后面会用到
      - ~/.affine/self-host/config:/root/.affine/config
      # blob storage
      - ~/.affine/self-host/storage:/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
      - DATABASE_URL=postgres://affine:affine@postgres:5432/affine
      - NODE_ENV=production
      - AFFINE_ADMIN_EMAIL=             ################## 修改为自己可用的邮箱
      - AFFINE_ADMIN_PASSWORD=          ################## 设置一个密码
      - TELEMETRY_ENABLE=false          ################## 关闭数据收集
  redis:
    image: redis:6.2.6
    container_name: affine_redis
    restart: unless-stopped
    volumes:
      - ~/.affine/self-host/redis:/data
    healthcheck:
      test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping']
      interval: 10s
      timeout: 5s
      retries: 5
  postgres:
    image: postgres:15-alpine
    container_name: affine_postgres
    restart: unless-stopped
    ############# 方便后面改人数限制
    ports:
      - '5432:5432'
    volumes:
      - ~/.affine/self-host/postgres:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -U affine']
      interval: 10s
      timeout: 5s
      retries: 5
    environment:
      POSTGRES_USER: affine
      POSTGRES_PASSWORD: affine
      POSTGRES_DB: affine
      PGDATA: /var/lib/postgresql/data/pgdata


登录设置

访问服务后登录系统可以通过用户名密码的方式,但是启动前设置在配置文件中的账号密码在登录的时候总是提示无效密码,无奈只能通过邮箱验证登录,如此则需要配置smtp服务。

在初次服务启动成功后,会在/home目录下生成一个.affine文件夹,编辑如下文件

vim ~/.affine/self-host/config/.env

###### 添加
MAILER_SENDER="发件人邮箱"
MAILER_USER="发件人邮箱登录账号"
MAILER_PASSWORD="发件人邮箱smtp授权码"
MAILER_HOST="smtp.163.com"         # 此处我用163的邮箱发件
MAILER_PORT="465"

账号权限设置

此时登录的账号为免费版账号,有很多限制,团队协作人数只有3人,此时需要修改数据库修改账号权限。

本人在虚拟机中尝试用pgadmin4连接数据库但是无法成功,提示无法解析的名称,如下图,也未找到答案,如有知道的请告知。

后本人通过宿主机用navicat连接成功,需要做如下配置:

1 将docker postgresql容器中的5432端口映射到虚拟机的5432端口:编辑启动服务的文件 连接数据库。users是用户表,features就是用户等级表,user_features是关联表。

查看features表,lifetime_pro_plan_v1 对应的memberLimit,修改自己想要的人数

上次编辑于:
贡献者: 李元昊