Seafile, your own Dropbox / OneDrive

We are going to see how to install and configure Seafile with docker compose

What is Seafile?

Seafile is an open-source, cross-platform file-hosting software system. Files are stored on a central server and can be synchronized with personal computers and mobile devices through apps. Files on the Seafile server can also be accessed directly via the server's web interface. Seafile's functionality is similar to other popular file hosting services such as Dropbox and Google Drive. The primary difference between Seafile and Dropbox/Google Drive is that Seafile is a self-hosted file sharing solution for private cloud applications. In private clouds, storage space and client connection limits are determined exclusively by the users' own infrastructure and settings rather than the terms and conditions of a cloud service provider.

Deployement

In order to install Seafile with docker compose you need to have a working docker environment, you can see how to do it by clicking the link below.

Start with docker and docker compose
How to install docker and docker compose on Debian 12

To deploy Seafile, simply use the following docker-compose.yaml file and edit the values:

  • MYSQL_ROOT_PASSWORD
  • DB_ROOT_PASSWD (same than MYSQL_ROOT_PASSWORD)
  • SEAFILE_ADMIN_EMAIL
  • SEAFILE_ADMIN_PASSWORD
  • /path/local/datas/ with the real path of a folder you want to use to store Seafile datas and database
---
services:
  seafile-db:
    image: mariadb:10.11
    container_name: seafile-db
    environment:
      MYSQL_ROOT_PASSWORD: A-SECRET-PASSWORD
      MYSQL_LOG_CONSOLE: true
    volumes:
      - /path/local/datas/seafile/db:/var/lib/mysql
    restart: always:

  memcached:
    image: memcached:1.6.18
    container_name: memcached
    entrypoint: memcached -m 256
    restart: always

  seafile:
    image: seafileltd/seafile-mc:11.0.11
    container_name: seafile
    ports:
      - 80:80
    volumes:
      - /path/local/datas/seafile/shared:/shared
    environment:
      DB_HOST: seafile-db
      DB_ROOT_PASSWD: A-SECRET-PASSWORD
      SEAFILE_ADMIN_EMAIL: [email protected]
      SEAFILE_ADMIN_PASSWORD: your-admin-password
      SEAFILE_SERVER_HOSTNAME: https://seafile.your.domain
      CSRF_TRUSTED_ORIGINS: seafile.your.domain
    depends_on:
      - seafile-db
      - memcached
    restart: always

Once your docker compose file saved you can launch your Seafile server with the command:

docker compose up -d

Configuration

Force the Two-Factor Authentication

Before the first login, I highly recommend you to activate and force the Two-Factor Authentication fot all the users.

You can do that by editing the file /path/local/datas/seafile/shared/seafile/conf/seahub_settings.py and add those 2 lines at the end

ENABLE_TWO_FACTOR_AUTH = True
ENABLE_FORCE_2FA_TO_ALL_USERS = True

Restart Seafile with docker compose restart seafile

First login

After a few seconds you can open a browser and go to http://server-ip and you should be able to access the login page

Log in with the credentials you set with SEAFILE_ADMIN_EMAIL and SEAFILE_ADMIN_PASSWORD on your docker compose file.

After the login, you will be invited to setup the Two-Factor authentication by scanning a QR Code with the application of your choice (Google Authenticator, Bitwarden etc...)

Once logged in, I recommend you to:

  1. Reset the admin password
  2. Edit the docker compose file and remove the line SEAFILE_ADMIN_PASSWORD
  3. Apply the changes with
docker compose up -d

Access Seafile in https and expose it publicly

Currently your Seafile server is only reachable from your home network, to expose it securely to internet you have several choices:

  • Reverse proxy, you can see how to deploy a reverse proxy with Traefik here
  • VPN

Reverse proxy with Traefik

I will show you how to do it with Traefik, it' s my to go reverse proxy to use with docker containers.

First you need to have Traefiky up and running, you can follow my post

https://2nistech.world/traefik-an-easy-reverse-proxy/

💡
Be sure your Traefik container is in the same network than your Seafile server

Now you have traefik up and running, you can add the followings labels to your docker compose file for Seafile.

    labels:
      - traefik.enable=true
      - traefik.http.routers.seafile.rule=Host(`seafile.your.domain`)
      - traefik.http.routers.seafile.entrypoints=websecure
      - traefik.http.routers.seafile.tls.certresolver=myresolver

The final results should be like this:

---
services:
  seafile-db:
    image: mariadb:10.11
    container_name: seafile-db
    environment:
      MYSQL_ROOT_PASSWORD: A-SECRET-PASSWORD
      MYSQL_LOG_CONSOLE: true
    volumes:
      - /path/local/datas/seafile/db:/var/lib/mysql
    restart: always:

  memcached:
    image: memcached:1.6.18
    container_name: memcached
    entrypoint: memcached -m 256
    restart: always

  seafile:
    image: seafileltd/seafile-mc:11.0.11
    container_name: seafile
    ports:
      - 80:80
    volumes:
      - /path/local/datas/seafile/shared:/shared
    environment:
      DB_HOST: seafile-db
      DB_ROOT_PASSWD: A-SECRET-PASSWORD
      SEAFILE_ADMIN_EMAIL: [email protected]
      SEAFILE_ADMIN_PASSWORD: your-admin-password
      SEAFILE_SERVER_HOSTNAME: https://seafile.your.domain
      CSRF_TRUSTED_ORIGINS: seafile.your.domain
    depends_on:
      - seafile-db
      - memcached
    restart: always
    labels:
      - traefik.enable=true
      - traefik.http.routers.seafile.rule=Host(`seafile.your.domain`)
      - traefik.http.routers.seafile.entrypoints=websecure
      - traefik.http.routers.seafile.tls.certresolver=myresolver
docker compose up -d

Now, you will be able to access your Seafile server with the url https://seafile.your.domain

You can also remove from the docker-compose.yaml file the line

- 80:80

If you don' t want to access your Seafile from the local IP address.

Finalisation

The last thing to do in the Seafile web console is to set the url you use to access Seafile to avoid issues with the avatars:

You can download the desktop et mobile applications by followings this link: https://www.seafile.com/en/download/

sources: