Deploy Seafile Server Through Docker
Recommended Server Minimums
- 2 Cores
- 2GB or more for memory.
- 1GB for swap if possible.
Steps
Firstly install docker and install install docker compose.
Create Docker Compose File
Copy and paste the following docker-compose.yml file to your server:
services:
seafile:
image: seafileltd/seafile-mc:${SEAFILE_VERSION}
container_name: seafile
ports:
- "80:80"
- "443:443"
volumes:
- ./volumes/seafile-data:/shared
logging:
driver: "local"
options:
max-size: "10m"
max-file: "3"
restart: always
environment:
- DB_HOST=db
- DB_ROOT_PASSWD=${DB_ROOT_PASSWORD}
- TIME_ZONE
- SEAFILE_ADMIN_EMAIL
- SEAFILE_ADMIN_PASSWORD
- SEAFILE_SERVER_HOSTNAME=${SEAFILE_FQDN}
- SEAFILE_SERVER_LETSENCRYPT=false
#- FORCE_HTTPS_IN_CONF=true
depends_on:
- db
- memcached
db:
image: mariadb:${MARIADB_VERSION}
container_name: seafile-mysql
restart: always
logging:
driver: "local"
options:
max-size: "10m"
max-file: "3"
environment:
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
- MYSQL_LOG_CONSOLE=true
volumes:
- ./volumes/seafile-db:/var/lib/mysql
memcached:
image: memcached:${MEMCACHED_VERSION}
container_name: seafile-memcached
restart: always
logging:
driver: "local"
options:
max-size: "10m"
max-file: "3"
command:
- --conn-limit=1024
- --memory-limit=128
- --threads=4
... then create a .env
file at the same level with the following settings, and fill them in:
# Specify the namespace of this service. Feel free to ignore this.
COMPOSE_PROJECT_NAME="seafile"
# Specify software versions.
SEAFILE_VERSION="11.0.13"
MARIADB_VERSION="10.11-jammy"
MEMCACHED_VERSION="1.5.6"
# Specify a strong random root password for the database
DB_ROOT_PASSWORD=""
# Specify the email and password of your first admin user. You will
# use these to log in for the first time.
SEAFILE_ADMIN_EMAIL="me@mydomain.com"
SEAFILE_ADMIN_PASSWORD=""
# Specify the URL of your seafile server
SEAFILE_FQDN="seafile.mydomain.com"
# Set the timezone, this is not that important.
TIME_ZONE="Etc/UTC"
A Note On Volumes
I used bind mounted volumes rather than named volumes for the seafile data and the database. This allows you to easily change the path if you need to use different disks. E.g. you may wish to have a server with an SSD and an HDD, and have the database on the SSD, with the seafile data on the HDD for cheap storage.
If you don't understand anything I just said, you probably want to just continue as-is.
Deploy!
Run the following command to deploy
docker-compose up
If you need to deploy "silently" and not see the output and tie-up your terminal, then you can use:
docker-compose up -d
CSRF Fix
On my fresh deployment, I got a CRSF error when I tried to log in. I found that I had to manually add the following to the seahub_settings.conf
file
in order to have seafile to work:
CSRF_TRUSTED_ORIGINS = ['https://seafile.pthub3.com']
Debugging
If you continue to hit issues, add the following line to your seahub_settings.conf file:
DEBUG=True
This helps a lot.
References
First published: 21st February 2021