seafile-compose.yml

version: '3.0'
services:
  db:
    image: mariadb:10.6
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password  # Requested, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
    volumes:
      - /data/seafile/db:/var/lib/mysql  # Requested, specifies the path to MySQL data persistent store.
    networks:
      - seafile-net

  memcached:
    image: memcached:1.6.18
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net

  elasticsearch:
    image: docker.seafile.top/seafileltd/elasticsearch:8.6.2
    container_name: seafile-elasticsearch
    environment:
      - discovery.type=single-node
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    mem_limit: 2g
    volumes:
      - /data/seafile/elasticsearch:/usr/share/elasticsearch/data
    networks:
      - seafile-net

  seafile:
    image: docker.seafile.top/seafileltd/seafile-pro-mc:11.0-latest
    container_name: seafile
    ports:
      - "8000:80"
    volumes:
      - /data/seafile/data:/shared
      - /data/seafile/deps/seafile-controller:/opt/seafile/seafile-pro-server-11.0.14/seafile/bin/seafile-controller
      - /data/seafile/deps/seaf-server:/opt/seafile/seafile-pro-server-11.0.14/seafile/bin/seaf-server
      - /data/seafile/deps/licenseparse.py:/opt/seafile/seafile-pro-server-11.0.14/seahub/seahub/utils/licenseparse.py
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=password
      - TIME_ZONE=Asia/Shanghai
      - SEAFILE_ADMIN_EMAIL=136xxxxxx771@139.com
      - SEAFILE_ADMIN_PASSWORD=password
      - SEAFILE_SERVER_LETSENCRYPT=false
      - SEAFILE_SERVER_HOSTNAME=yunpan.waringid.me
    depends_on:
      - db
      - memcached
      - elasticsearch
    networks:
      - seafile-net

networks:
  seafile-net:   
chmod -R 777 /data/seafile/elasticsearch
vim /data/seafile/data/seafile/conf/seahub_settings.py

seahub_settings.py

CSRF_TRUSTED_ORIGINS = ["https://yunpan.waringid.me"]

Seafile 整合 sdoc-server

SeaDoc 是一个在线协同文档,并有文档的流程管理功能。SeaDoc 围绕以下的关键想法进行设计:

  • 富有表现力的并且易于使用的编辑器
  • 审阅和批准工作流,可更好地控制文档内容的修改
  • 可以链接相关的文档
  • AI 集成,以简化内容生成和管理
  • 丰富的 API,可以用于自动化文档生成和处理

SeaDoc 的使用场景包括:

  • 产品和技术文档的撰写
  • 创建知识库文章和在线手册
  • 构建团队内部维基
以下配置场景基于 seafile 和 sdoc 都在同一台主机的容器方式配置。

手动创建 SeaDoc 数据库

SeaDoc 和 Seafile 共享 MySQL 服务。在 Seafile MySQL 中创建数据库sdoc_db。

mysql 用户 seafile 的密码保存在 /data/seafile/data/seafile/conf/seahub_settings.py 中。


docker exec -it seafile-mysql sh
mysql -uroot -p****

create database if not exists sdoc_db charset utf8mb4;
GRANT ALL PRIVILEGES ON `sdoc_db`.* to `seafile`@`%.%.%.%`;

修改 seafile 服务器的 nginx.conf 文件

将以下内容添加到 :/data/seafile/data/nginx/conf/seafile.nginx.conf

location /sdoc-server/ {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
        add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
        if ($request_method = 'OPTIONS') {
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
            add_header Access-Control-Allow-Headers "deviceType,token, authorization, content-type";
            return 204;
        }
        proxy_pass         http://sdoc-server:7070/;
        proxy_redirect     off;
        proxy_set_header   Host              $host;
        proxy_set_header   X-Real-IP         $remote_addr;
        proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host  $server_name;
        proxy_set_header   X-Forwarded-Proto $scheme;
        client_max_body_size 100m;
    }
    location /socket.io {
        proxy_pass http://sdoc-server:7070;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_redirect off;
        proxy_buffers 8 32k;
        proxy_buffer_size 64k;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

  }

在 seafiel.yml 增加 sdoc 配置

    sdoc-server:
      image: seafileltd/sdoc-server:latest
      container_name: sdoc-server
      ports:
        - 7070:7070
        - 8888:8888
      volumes:
        - /data/seafile/seadoc-data/:/shared
      environment:
        - DB_HOST=db
        - DB_PORT=3306
        - DB_USER=seafile
        - DB_PASSWD=29329XXX-bac6-XXXX
        - DB_NAME=sdoc_db
        - TIME_ZONE=Asia/Shanghai # Optional, default is UTC. Should be uncomment and set to your local time zone.
        - SDOC_SERVER_LETSENCRYPT=false # Whether to use https or not.
        - SDOC_SERVER_HOSTNAME=192.168.182.53 # Specifies your host name if https is enabled.
        - SEAHUB_SERVICE_URL=http://192.168.182.53:8003
      networks:
        - seafile-net

启动 SeaDoc

docker compose -f seafile.yml down
docker compose -f seafile.yml up

等待几分钟程序初始化完成后,查看配置文件 /opt/seadoc-server/sdoc-server/conf/sdoc_server_config.json,记录下 private_key 的内容,稍后用于编辑 Seafile 配置文件。

Seafile 配置

修改seahub_settings.py:

ENABLE_SEADOC = True
SEADOC_PRIVATE_KEY = 'fc-nfb4#y281&yq(n+'
SEADOC_SERVER_URL = 'http://192.168.182.53:8003/sdoc-server'
FILE_CONVERTER_SERVER_URL = 'http://sdoc-server:8888'

启用配置

docker exec -it seafile bash
cd  seafile-server-latest/
./seafile.sh  restart 
./seahub.sh restart

  • No labels

2 Comments

  1. Anonymous

    按照教程一步步操作下来,发现几个小问题

    1.创建 SeaDoc 数据库,docker exec it seafile-mysql sh 应为 docker exec -it seafile-mysql sh

    2.配置数据库sdoc-sb权限时,GRANT ALL PRIVILEGES ON `sdoc_db`.* to `seafile`@`%.%.%.%`;这条命令会报错,ERROR 1133 (28000): Can't find any matching row in the user table,能力有限不明白什么意思,改成GRANT ALL PRIVILEGES ON `sdoc_db`.* to `seafile`@`%`就可以了,但是不清楚这两条命令有何区别

    3.修改 seafile 服务器的 nginx.conf 文件,如果直接复制博主的配置并写入配置文件,nginx检查会报错,经排查发现是字符集的问题,博主这个字符集用的是UTF-8,能正常使用的字符集是GB2312,这个坑还真是头一次遇到,只凭眼看的话根本是毫无区别,但nginx就是执行不了

    4.配置好之后启动seafile正常,但是seadoc无法正常工作,seadoc版本是0.7,另外就是教程提到mysql 用户 seafile 的密码保存在 /data/seafile/data/seafile/conf/seahub_settings.py 中,但是这个密码用在何处?好像配置中也没有用到

    1. You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.
    1. 虚拟的现实

      1、感谢提醒,文档记录有误,已调整

      2、‘%.%.%.%’匹配的是 IP 地址 '%'匹配更广泛,包括 localhost 和 ip 地址

      3、感谢提醒,这个应该是文档软件字符集的问题。后续的内容考虑直接贴附件上去

      4、seadoc 无法正常工作要看出错的页面提示,大部分的情况是 SEADOC_SERVER_URL 配置问题,你可以直接访问这个地址看看是否正常来验证。seeafile 的密码用在 seadoc 容器配置中

      现在最新的版本是 12.0.11,sdoc-server 版本是 1.0.5(和 0.7 版本相比有很大的变化了)你可以对照参考 https://wiki.waringid.me/x/WgBmB