diff --git a/Dockerfile b/Dockerfile index 071df3d..dc7a99f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,23 +16,28 @@ FROM debian:jessie +# Prevent the packages installation to halt. ENV DEBIAN_FRONTEND noninteractive +# Prepare the directories. RUN mkdir /.seafile ;\ mkdir /.supervisord ;\ mkdir /volume +# Put the core functionalities into the image. COPY assets/seafile.list /etc/apt/sources.list.d/ COPY assets/supervisord.conf /.supervisord/ COPY assets/infinite-seaf-cli-start.sh / COPY entrypoint.sh / +# Install both seafile-cli and supervisord. RUN apt-key adv \ --keyserver hkp://keyserver.ubuntu.com:80 \ --recv-keys 8756C4F765C9AC3CB6B85D62379CE192D401AB61 RUN apt-get update ;\ apt-get install -o Dpkg::Options::="--force-confold" -y seafile-cli supervisor +# Configure the user. ENV UNAME=seafuser ENV UID=1000 ENV GID=1000 diff --git a/README.md b/README.md index 28096ed..667e633 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,67 @@ -# Seafile Client +# Available tags. + +# Purpose +Docker Seafile Client allow you to sync a Seafile library within a container. Essentially, you have the ability to: +* **Share** data from a **Seafile library** as a volume to **other containers**. +## Seafile? +[Seafile is a cloud storage software](https://www.seafile.com/). + + +# Usage +The *Seafile* daemon is running from `/.seafile/` and `~/.ccnet`. +The library is synced at `/volume/`. + +The *Seafile* daemon is managed with *supervisord* since it can't run as a foreground process. +The *supervisord* is running from `/.supervisord/`, the `supervisord.conf`, `supervisord.log` and `supervisord.pid` can be found there. +*supervisord* also manage a shell script, `/seaf-cli-start.sh` which run `seaf-cli start` every hour: the synchronisation might not work properly if the previously is not run from times to times, for an unresolved reason. +## Examples +You would have to share the path `/volume/` to other containers, with the following approaches: +### Docker CLI +`docker run ` +### docker-compose +```yaml +version: "3.4" + +services: + seafile-sync: + image: registry.gitlab.com/flwgns-docker/docker-seafile-client:latest + volumes: + - your_shared_volume:/volume + environment: + - SEAF_SERVER_URL= # The URL to your Seafile server. + - SEAF_USERNAME= # Your Seafile username. + - SEAF_PASSWORD= # Your Seafile password + - SEAF_LIBRARY_UUID= # The Seafile library UUID you want to sync with. + - UID= # Default is 1000. + - GID= # Default is 1000. + +volumes: + your_shared_volume: +``` + + +# Environment variables +The following environment variable are available. + +## Seafile +This Docker **must be configured with the following**, **otherwise** it **will not run**: +## SEAF_SERVER_URL +The URL to your Seafile server. +## SEAF_USERNAME +Your Seafile account's username. +## SEAF_PASSWORD +Your Seafile account's password. +## SEAF_LIBRARY_UUID +The Seafile library UUID you want to use. + +## User permissions +This Docker is **not running as `root` but as `seafuser`**. You can override the user/group ID used with: +### UID +The user ID defaults to `1000`. You may want to override this variable to prevent permission issues. +### GID +The group ID defaults to `1000`. Similarly, you may want to override this variable to prevent permission issues. + +# Source code +This Docker image is licensed under GPLv3. +The source code is available in [gitlab.com/flwgns-docker/docker-seafile-client](https://gitlab.com/flwgns-docker/docker-seafile-client/). \ No newline at end of file diff --git a/assets/supervisord.conf b/assets/supervisord.conf index fb053cf..4b38bba 100644 --- a/assets/supervisord.conf +++ b/assets/supervisord.conf @@ -14,12 +14,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# Run in the foreground to keep the container running. [supervisord] nodaemon=true +# Manage the Seafile daemon. [unix_http_socket] file=/seafile/seafile-data/seafile.sock +# Manage the infinite `seaf-cli start`. [program:seaf-cli-start-loop] command=/bin/bash /infinite-seaf-cli-start.sh process_name=%(program_name)s diff --git a/docker-compose.yml b/docker-compose.yml index e7aaffd..46072ee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,16 @@ version: "3.4" services: seafile-sync: - image: seafvol:latest + image: registry.gitlab.com/flwgns-docker/docker-seafile-client:latest + volumes: + your_shared_volume:/volume environment: - - SERVER= - - USERNAME= - - PASSWORD= - - LIBRARY_ID= + - SEAF_SERVER= + - SEAF_USERNAME= + - SEAF_PASSWORD= + - SEAF_LIBRARY_UUID= - UID= - - GID= \ No newline at end of file + - GID= + +volumes: + your_shared_volume: \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index e26ab88..9983944 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -22,9 +22,13 @@ supervisord_conf=/.supervisord/supervisord.conf supervisord_pid=/.supervisord/supervisord.pid supervisord_log=/.supervisord/supervisord.log +# Safely initialize Seafile. /usr/bin/seaf-cli init -d /.seafile while [ ! -f $seafile_ini ]; do sleep 1; done +# Safely start the Seafile daemon. /usr/bin/seaf-cli start while [ ! -S $seafile_sock ]; do sleep 1; done -/usr/bin/seaf-cli sync -u $USERNAME -p $PASSWORD -s $SERVER -l $LIBRARY_ID -d /volume +# Start the synchronisation. +/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume +# Start the supervisord. /usr/bin/supervisord -u $UNAME -c $supervisord_conf -j $supervisord_pid -l $supervisord_log \ No newline at end of file