前言
飞牛应用市场自带的 affine安装了几次总是启动失败,而且版本也不是最新的,因此参照affine官方的文档,自己在Docker部署了affine,目前工作良好,同步功能也全部正常。这里把折腾的过程写下来,供大家参考。
具体部署过程
第一步部(step 1)
- 在Docker文件夹下新建affine文件夹,并建立config、postgres、postgresql、storage四个 子文件夹 ,如图所示。

第二步 (step 2)
- 新建一个.env环境变量文件,具体内容如下,并上传至affine文件下。
#The folder for Postgres data, usually to be the one in step 1 with '/postgres' suffix
DB_DATA_LOCATION=./postgres
#The folder for uploaded blobs, usually to be the one in step 1 with '/storage' suffix
UPLOAD_LOCATION=./storage
#The folder for custom configurations, usually to be the one in step with '/config' suffix
CONFIG_LOCATION=./config
#DATABASE credentials and names to initialize Postgres
#数据库用户名,请自己填写,替换username
DB_USERNAME=username
#数据库密码,自己填写替换password
DB_PASSWORD=password
DB_DATABASE=affine
第三步(step 3)
- 打开Docker,compose,新增项目,起个项目名称,这里就用affine,目录就选刚刚建立的affine目录,创建docker-compose.yml,具体内容如下
name: affine
services:
affine:
image: ghcr.io/toeverything/affine:${AFFINE_REVISION:-stable}
container_name: affine_server
# 冒号前的端口替换为你要用的端口
ports:
- '3010:3010'
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
affine_migration:
condition: service_completed_successfully
volumes:
# 冒号前的地址替换为你第一步建立的文件夹的地址
- /vol1/1000/Docker/affine/storage:/root/.affine/storage
- /vol1/1000/Docker/affine/config:/root/.affine/config
env_file:
- .env
environment:
- REDIS_SERVER_HOST=redis
- DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@postgres:5432/${DB_DATABASE:-affine}
- AFFINE_INDEXER_ENABLED=false
restart: unless-stopped
affine_migration:
image: ghcr.io/toeverything/affine:${AFFINE_REVISION:-stable}
container_name: affine_migration_defualt
volumes:
# 冒号前的地址替换为你第一步建立的文件夹的地址
- /vol1/1000/Docker/affine/storage:/root/.affine/storage
- /vol1/1000/Docker/affine/config:/root/.affine/config
command: ['sh', '-c', 'node ./scripts/self-host-predeploy.js']
env_file:
- .env
environment:
- REDIS_SERVER_HOST=redis
- DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@postgres:5432/${DB_DATABASE:-affine}
- AFFINE_INDEXER_ENABLED=false
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
redis:
image: redis
container_name: affine_redis
healthcheck:
test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping']
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
postgres:
image: pgvector/pgvector:pg16
container_name: affine_postgres
volumes:
# 冒号前的地址替换为你第一步建立的文件夹的地址
- /vol1/1000/Docker/affine/postgres:/var/lib/postgresql/data
environment:
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_DATABASE:-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', "${DB_USERNAME}", '-d', "${DB_DATABASE:-affine}"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
-
完成后点击构建,构建完成后启动,共有四个容器,其中第二个会在运行完成后自动关闭,不会影响使用。

-
输入IP+端口号登陆网页,第一次会进入管理面板,在这里创建一个账号就可以使用了,可以创建多个账号多人使用,还有多人协作功能,还没怎么研究。

-
创建账号后再次登录,就可以使用网页版本笔记了。

Affine客户端的使用