Seafile部署

开发版官网部署文档:

https://cloud.seafile.com/published/seafile-manual-cn/docker/%E7%94%A8Docker%E9%83%A8%E7%BD%B2Seafile.md

Docker-compose.yml 内容

  1. version: '2.0'
  2. services:
  3. db:
  4. image: mariadb:10.5
  5. container_name: seafile-mysql
  6. environment:
  7. - MYSQL_ROOT_PASSWORD=db_dev # Requested, set the root's password of MySQL service.
  8. - MYSQL_LOG_CONSOLE=true
  9. volumes:
  10. - /opt/seafile-mysql/db:/var/lib/mysql # Requested, specifies the path to MySQL data persistent store.
  11. networks:
  12. - seafile-net
  13. memcached:
  14. image: memcached:1.6
  15. container_name: seafile-memcached
  16. entrypoint: memcached -m 256
  17. networks:
  18. - seafile-net
  19. seafile:
  20. image: seafileltd/seafile-mc:latest
  21. container_name: seafile
  22. ports:
  23. - "10080:80"
  24. # - "443:443" # If https is enabled, cancel the comment.
  25. volumes:
  26. - /opt/seafile-data:/shared # Requested, specifies the path to Seafile data persistent store.
  27. environment:
  28. - DB_HOST=db
  29. - DB_ROOT_PASSWD=db_dev # Requested, the value shuold be root's password of MySQL service.
  30. # - TIME_ZONE=Asia/Shanghai # Optional, default is UTC. Should be uncomment and set to your local time zone.
  31. - SEAFILE_ADMIN_EMAIL=me@example.com # Specifies Seafile admin user, default is 'me@example.com'.
  32. - SEAFILE_ADMIN_PASSWORD=asecret # Specifies Seafile admin password, default is 'asecret'.
  33. - SEAFILE_SERVER_LETSENCRYPT=false # Whether use letsencrypt to generate cert.
  34. - SEAFILE_SERVER_HOSTNAME=seafile.example.com # Specifies your host name.
  35. depends_on:
  36. - db
  37. - memcached
  38. networks:
  39. - seafile-net
  40. networks:
  41. seafile-net:

启动停止

如同正常的 docker-compose 一样管理就可以

  1. # 启动
  2. docker-compose up -d
  3. # 停止
  4. docker-compose down

线上版本配置部署

线上版本如果需要绑定域名配 ssl,而且要使用宿主机的 nginx 来代理,需要修改 docker-compose.yml 和配置文件。

docker-compose.yml 文件修改,可以参考:

  1. version: '2.0'
  2. services:
  3. db:
  4. image: mariadb:10.5
  5. container_name: seafile-mysql
  6. environment:
  7. - MYSQL_ROOT_PASSWORD=db_dev # Requested, set the root's password of MySQL service.
  8. - MYSQL_LOG_CONSOLE=true
  9. volumes:
  10. - /opt/seafile-mysql/db:/var/lib/mysql # Requested, specifies the path to MySQL data persistent store.
  11. networks:
  12. - seafile-net
  13. memcached:
  14. image: memcached:1.6
  15. container_name: seafile-memcached
  16. entrypoint: memcached -m 256
  17. networks:
  18. - seafile-net
  19. seafile:
  20. image: seafileltd/seafile-mc:latest
  21. container_name: seafile
  22. ports:
  23. - "10080:80" # 映射到 10080
  24. # - "443:443" # If https is enabled, cancel the comment.
  25. volumes:
  26. - /opt/seafile-data:/shared # Requested, specifies the path to Seafile data persistent store.
  27. environment:
  28. - DB_HOST=db
  29. - DB_ROOT_PASSWD=db_dev # Requested, the value shuold be root's password of MySQL service.
  30. # - TIME_ZONE=Asia/Shanghai # Optional, default is UTC. Should be uncomment and set to your local time zone.
  31. - SEAFILE_ADMIN_EMAIL=me@example.com # Specifies Seafile admin user, default is 'me@example.com'.
  32. - SEAFILE_ADMIN_PASSWORD=asecret # Specifies Seafile admin password, default is 'asecret'.
  33. - SEAFILE_SERVER_LETSENCRYPT=false # Whether use letsencrypt to generate cert. # 不需要开启容器内的 ssl 证书申请
  34. - SEAFILE_SERVER_HOSTNAME=seafile.example.com # Specifies your host name. # 这边配置为公开域名
  35. depends_on:
  36. - db
  37. - memcached
  38. networks:
  39. - seafile-net
  40. networks:
  41. seafile-net:

在 nginx 中配置域名,并 proxy_pass 到应用的 10080 端口后,在 nginx 上配置自己的 ssl。

现在网站可以打开并登录了,但上传的文件则是 http 协议的,因为 docker-compose 中没有打开 ssl 开关,我们自己在 nginx 管理了 ssl,所以这边要另外改一下 seafile 的配置:

  1. cat /opt/seafile-data/conf/seahub.conf
  2. 修改里面的两处域名,改为 https 的域名,然后测试一下文件上传下载功能。

备份与恢复

只要备份 /opt/seafile-data 及 /opt/seafile-mysql 即可。