haiwen/seafile-docker

Why is seafile only one container?

wucke13 opened this issue ยท 24 comments

Seafile can be decomposed into seafile, seahub (who share some files), mariadb/mysql and nginx. Of course one might argue that seafile and seahub shall run in one container as they both form two components of one application and must be on the same version. However, I can't see a good reason why mysql and nginx are ran from the same container.

According to Docker itself, it is considered best practice to decouple applications into there components (https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#decouple-applications).

Why does the Seafiles Dockerfile completely evade this?

Today I stumbled across a practical reason why the current attemp breaks things.
For some reason seahub died today. So, my seafile server was not available to my users. However, as the main process in the server kept running, docker did not use the restart: always to restart the server. So I had to manually restart the server, which then magically let all problems go.

TL;DR: Having multiple processes in one container breaks various docker features, for example restart on exit.

On a personal note, it would also be nice to have the ability to use a central database instead of the one in the container.

Another note: this would solve #89 too - even though #89 can be resolved without it.

Maybe somebody can build or edit the docker file to make this possible?

This would include providing a docker-compose.yml. There are some caveats though.

  • Handling of GC (as it stops the main process of the seafile container)?
  • Shall we include switch to official images if possible?
  • What about integration of seafile-pro? I don't own a pro license nor do I have any experience on that

In summary, it would be interesting to know why the current setup is not composed, maybe there is a naughty thing we missed so far.

I would also like to express my wish for a multi container setup in best case provided with docker-compose

I made pull request #110 to address this issue.
Let me know what you think.
So far only works on the standard sea file.

I actually don't see any possibility to backup the mysql tables. A multi container setup would resolve this problem.

@drummerroma docker exec -it seafile bash

@shoeper yes, you are right. But what I would prefer to do is a more docker-style solution without the need to enter in the container. Like https://github.com/selim13/docker-automysqlbackup. This is actually not possible without decomposing the containers.

I don't have time to try it out but don't see a reason why it shouldn't work.

tholu commented

An official docker-compose.yml would make deployments of seafile much easier. ๐Ÿ‘

Hello,

We created a compose setup to help us with setting up a development environment for Seahub.

The setup is probably missing a few bits to be production ready (Nginx, Gunicorn), but it will get you an environment you would get after following this guide: https://manual.seafile.com/deploy/using_mysql.html.

The compose sets up 4 containers, CCNET, Seafile-server, Seahub, and Mysql. I suppose it should not be too difficult to add Gunicorn and Nginx to that.

You can find our setup here: https://github.com/HumanBrainProject/seafile-compose

This is really needed. Currently I'm using docker-compose with a 3rd party image because I need to run behind an existing nginx proxy with separated mysql service. (see compose file bellow if helpful to anyone)

now im looking to upgrade to seafile pro however I have no upgrade path :(

would love to see @kingsukhoi pull request merged. Having an official image and upgrade path would be ideal :)

version: '2'

networks:
  db_net:
  proxy_net:
    external: true

services:

  seafile:
    image: gronis/seafile
    container_name: seafile
    restart: unless-stopped
    depends_on:
      - seafile-db
    networks:
      - proxy_net
      - db_net
    volumes:
      - /SeafileData/data:/seafile:rw
    ports:
      - 8000:8000
      - 8082:8082
    environment:
      - VIRTUAL_HOST=seafile.example.com
      - LETSENCRYPT_HOST=seafile.example.com
      - LETSENCRYPT_EMAIL=admin@example.com
      - VIRTUAL_PORT=8082
      - SEAFILE_NAME=Seafile
      - SEAFILE_ADDRESS=seafile.example.com
      - SEAFILE_ADMIN=admin@example.com
      - SEAFILE_ADMIN_PW=secret
      - MYSQL_SERVER=seafile-db
      - MYSQL_USER=seafile
      - MYSQL_USER_PASSWORD=mysqlsecret
      - MYSQL_ROOT_PASSWORD=mysqlsupersecret

  seafile-db:
    networks:
      - db_net
    image: wangxian/alpine-mysql:latest
    container_name: seafile-db
    restart: unless-stopped
    volumes:
      - /SeafileData/seafile-db-data:/app
      - /SeafileData/seafile-db-lock:/run/mysqld
    environment:
      - MYSQL_ROOT_PASSWORD=mysqlsupersecret

Seafile can be decomposed into seafile, seahub (who share some files), mariadb/mysql and nginx.

... and one could mention as well that if the containers were decoupled, one could not only use it with docker-compose, but also with Kubernetes ๐Ÿ˜ƒ That would (especially for larger installations) allow for better scaling and distribution of load - e.g. scale seahub and seafile Pods independently depending on the actual load.

I would like to add that this would also be very beneficient for the seafile-pro docker setup, as it could remove the depedency on jdk and elasticsearch from the main image.

In the last few days, I have been working on a docker image which only runs the seafile server and/or the seafile hub. You can check it out here: tbleiker/seafile-docker. Any suggestions are welcome! However, it is still under development and only tested on two servers so far... so things might blow up ๐Ÿ˜„

Edit: does not support seafile pro (yet...)

It would be great to have an option to use sqlite instead of mysql, since my instance has only two users

Seafile 7.0 switched to multiple containers. You can find upgrade instructions here: https://download.seafile.com/published/support/docker/6.3%20upgrade%20to%207.0.md

@freeplant Nice! Thanks a lot

Awesome!
is there a multi-container version for Seafile pro ?

jmooo commented

The 7.0 docs don't mention nginx or certbot, do those still live in the seafile container or have they been removed and you need to run your own nginx instance now?

Nginx and certbot are in the seafile container.

I miss the single container times. Was a lot simpler than having to do multiple.