Merge changes from milestone--2.0 into master

This commit is contained in:
flow.gunso
2020-01-07 21:02:55 +01:00
32 changed files with 489 additions and 769 deletions

View File

@@ -4,37 +4,62 @@ services:
- docker:dind - docker:dind
stages: stages:
- build_publish - build
- test
- publish
before_script: before_script:
- apk add bash - apk add bash git
- /bin/bash .utilities/check.sh
cron_or_supervisord: build.tags:
stage: build_publish stage: build
script: script: /bin/bash -e .utilities/build.tags.sh
- /bin/bash utils/publish/feature--cron-or-supervisord.sh
only:
- feature--cron-or-supervisord
staging:
stage: build_publish
script:
- /bin/bash utils/publish/staging.sh
only:
- staging
production:
stage: build_publish
script:
- /bin/bash utils/publish/production.sh
only: only:
- tags - tags
except: artifacts:
- branches paths:
- $CI_PROJECT_NAME.tar
build.schedules:
stage: build
script: /bin/bash -e .utilities/build.schedules.sh
only:
- schedules
artifacts:
paths:
- $CI_PROJECT_NAME.tar
test:
stage: test
script: /bin/bash -e .utilities/test.sh
only:
- tags
- schedules
artifacts:
paths:
- $CI_PROJECT_NAME.tar
publish.tags:
stage: publish
script: /bin/bash -e .utilities/publish.tags.sh
only:
- tags
artifacts:
paths:
- $CI_PROJECT_NAME.tar
publish.schedules:
stage: publish
script: /bin/bash -e .utilities/publish.schedules.sh
only:
- schedules
artifacts:
paths:
- $CI_PROJECT_NAME.tar
update_docker_hub_full_description: update_docker_hub_full_description:
stage: build_publish stage: publish
script: script: /bin/bash -e .utilities/update-docker-hub-full-description.sh
- /bin/bash utils/publish/update-docker-hub-full-description.sh
only: only:
- master - master

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -16,20 +16,17 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# Define variable shortcuts for readability purposes. # Hard reset to the latest tag.
seafile_ini=~/.ccnet/seafile.ini latest_version=$(git describe --abbrev=0)
seafile_sock=~/.seafile/seafile-data/seafile.sock git reset --hard $latest_version
# Prepare the directories. cp -R tests seafile-client/
mkdir ~/.seafile cd seafile-client/
# Safely initialise the Seafile client. docker build \
/usr/bin/seaf-cli init -d ~/.seafile --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
while [ ! -f $seafile_ini ]; do sleep 1; done --build-arg VCS_REF=$(git rev-parse --short HEAD) \
--build-arg VERSION=$latest_version \
--tag $CI_PROJECT_NAME:build .
# Safely start the Seafile daemon. docker save --output ../$CI_PROJECT_NAME.tar $CI_PROJECT_NAME:build
/usr/bin/seaf-cli start
while [ ! -S $seafile_sock ]; do sleep 1; done
# Start the synchronisation.
/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume

View File

@@ -1,5 +1,7 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -14,17 +16,13 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# Run in the foreground to keep the container running. cp -R tests seafile-client/
[supervisord] cd seafile-client/
nodaemon=true
# Manage the Seafile daemon. docker build \
[unix_http_socket] --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
file=~/.seafile/seafile-data/seafile.sock --build-arg VCS_REF=$(git rev-parse --short HEAD) \
--build-arg VERSION=$latest_version \
--tag $CI_PROJECT_NAME:build .
# Manage the infinite `seaf-cli start`. docker save --output ../$CI_PROJECT_NAME.tar $CI_PROJECT_NAME:build
[program:seaf-cli-start-loop]
command=/bin/bash /home/seafuser/seafile-healthcheck.sh
process_name=%(program_name)s
numprocs=1
autostart=true

47
.utilities/check.sh Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019-2020, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Check the CI pipeline sources.
if ! [[ "$CI_PIPELINE_SOURCE" == "push" || "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
echo "CI pipelines are only allowed from the push and schedule sources"
exit 1
fi
# Check the schedule target for the scheduled CI pipelines.
if [[ "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
if [[ -z "$SCHEDULE_TARGET" ]]; then
echo "\$SCHELUDE_TARGET was not provided."
exit 1
fi
if ! [[ "$SCHEDULE_TARGET" == "weekly" ]]; then
echo "\$SCHEDULE_TARGET $SCHEDULE_TARGET is not known."
exit 1
fi
fi
# Check the tag is properly defined on job other than update_docker_hub_full_description job,
# on pushed CI pipelines.
if [[ "$CI_PIPELINE_SOURCE" == "push" ]]; then
if ! [[ "$CI_JOB_NAME" == "update_docker_hub_full_description" ]]; then
if [[ -z "$CI_COMMIT_TAG" && "$CI_COMMIT_TAG" =~ ^[0-9]+[.][0-9]+[.][0-9]+$ ]]
echo "The \$CI_COMMIT_TAG $CI_COMMIT_TAG does not match the MAJOR.Minor.revision layout."
exit 1
fi
fi
fi

View File

@@ -0,0 +1,34 @@
# !/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019-2020, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
SCRIPT_DIRECTORY=$(dirname ${BASH_SOURCE[0]})
source $SCRIPT_DIRECTORY/utilities.sh
load_images_artifacts
tags=("latest")
for version_component in "$(git describe --abbrev=0 | tr '.' '\n')"; do
tag+="$version_component"
tags+=("$tag")
tag+="."
done
echo $CI_REGISTRY_BOT_PASSWORD | docker login --password-stdin --username $CI_REGISTRY_BOT_USERNAME
for tag in "${tags[@]}"; do
docker tag $CI_PROJECT_NAME:$tag $CI_REGISTRY_IMAGE:build
docker push $CI_REGISTRY_IMAGE:$tag
done

View File

@@ -0,0 +1,34 @@
# !/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019-2020, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
SCRIPT_DIRECTORY=$(dirname ${BASH_SOURCE[0]})
source $SCRIPT_DIRECTORY/utilities.sh
load_images_artifacts
tags=("latest")
for version_component in "$CI_COMMIT_TAG"; do
tag+="$version_component"
tags+=("$tag")
tag+="."
done
echo $CI_REGISTRY_BOT_PASSWORD | docker login --password-stdin --username $CI_REGISTRY_BOT_USERNAME
for tag in "${tags[@]}"; do
docker tag $CI_PROJECT_NAME:$tag $CI_REGISTRY_IMAGE:build
docker push $CI_REGISTRY_IMAGE:$tag
done

26
.utilities/test.sh Normal file
View File

@@ -0,0 +1,26 @@
# !/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019-2020, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
SCRIPT_DIRECTORY=$(dirname ${BASH_SOURCE[0]})
source $SCRIPT_DIRECTORY/utilities.sh
load_images_artifacts
docker run \
--interactive \
--attach stderr \
$CI_PROJECT_NAME:build /tests/test_binaries.sh

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by

21
.utilities/utilities.sh Normal file
View File

@@ -0,0 +1,21 @@
# !/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019-2020, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
load_images_artifacts() {
docker load --input $CI_PROJECT_NAME.tar
}

View File

@@ -1,40 +1,50 @@
### [1.2.1] - 2019/05/02 # __[2.0.0](https://gitlab.com/flwgns-docker/seafile-client/-/tags/2.0.0)__ | _2020/01/06_
- Support 2FA authentication through `oathtool` using the secret key
- Support for upload/download limits
- Support for Seafile library password
- Allow skipping SSL certificates verifications
- Drop Bash/supervisord/cron implementations in favor of showing seafile's log
- Implement basic integration tests that check expected binairies
- Improve continuous integration though splitted jobs
- Revise README
- Change the volume path from /volume to /library for consistency
### __[1.2.1](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.2.1)__ | _2019/12/29_
- Fix #4: - Fix #4:
- Switch base image from Debian oldoldstable Jessie to Debian stable Buster to fix unmet dependencies of `seafile-cli` to `python-future` and `python-searpc` - Switch base image from Debian oldoldstable Jessie to Debian stable Buster to fix unmet dependencies of `seafile-cli` to `python-future` and `python-searpc`
- Replace `;` with `&&` as commands separators in the Dockerfile's `RUN` to properly report failed commands at CI - Replace `;` with `&&` as commands separators in the Dockerfile's `RUN` to properly report failed commands at CI
## __[1.2.0](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.2.0)__ | _2019/05/02_
## [1.2.0] - 2019/05/02
- Replace _supervisord_ with _cron_ for running the front job that keeps the container up. It uses less resources. - Replace _supervisord_ with _cron_ for running the front job that keeps the container up. It uses less resources.
- Improve the __infinite-seaf-cli-start.sh__ into __seafile-healthcheck.sh__. The Seafile daemon will not be restarted if it's state are either _downloading_ or _committing_, which otherwise is problematic. - Improve the __infinite-seaf-cli-start.sh__ into __seafile-healthcheck.sh__. The Seafile daemon will not be restarted if it's state are either _downloading_ or _committing_, which otherwise is problematic.
### [1.1.2] - 2019/04/18 ### __[1.1.2](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.1.2)__ | _2019/04/18_
- Slim down the Docker image, from 102MB to 67MB, gaining 35MB, reducing size by 34%. - Slim down the Docker image, from 102MB to 67MB, gaining 35MB, reducing size by 34%.
### [1.1.1] - 2019/04/18 ### __[1.1.1](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.1.1)__ | _2019/04/18_
- Because of the infinite-seaf-cli-start loop, within the container was running many seaf-daemons. Now, the infinite loop stop the current seaf-daemon before starting it again. (see #3) - Because of the infinite-seaf-cli-start loop, within the container was running many seaf-daemons. Now, the infinite loop stop the current seaf-daemon before starting it again. (see #3)
## [1.1.0] - 2019/04/09 ## __[1.1.0](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.1.0)__ | _2019/04/09_
- The container now actually use the UID/GID provided to it: - The container now actually use the UID/GID provided to it:
The container entrypoint is run with root, then another entrypoint is run by the container's user, seafuser, to run the Seafile client. The container entrypoint is run with root, then another entrypoint is run by the container's user, seafuser, to run the Seafile client.
### [1.0.6] - 2019/03/25 ### __[1.0.6](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.6)__ | _2019/03/25_
- More minor fixes from v1.0.4 - More minor fixes from v1.0.4
### [1.0.5] - 2019/03/25 ### __[1.0.5](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.5)__ | _2019/03/25_
- Minor fixes from v1.0.4 - Minor fixes from v1.0.4
### [1.0.4] - 2019/03/25 ### __[1.0.4](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.4)__ | _2019/03/25_
- Fix the build target detection (@a52559ddb38a64d7fceaa8bf9b8afd7356ccc439) - Fix the build target detection (@a52559ddb38a64d7fceaa8bf9b8afd7356ccc439)
- Login to the Docker Hub from within the script, not the gitlab-ci.yml, using (@72bab017c1167b8ab35cef3cc709ff83686eaca4, @f69483354a4cf8afdbea89ef2bb1d9a9b7b2ac10) - Login to the Docker Hub from within the script, not the gitlab-ci.yml, using (@72bab017c1167b8ab35cef3cc709ff83686eaca4, @f69483354a4cf8afdbea89ef2bb1d9a9b7b2ac10)
- Require Bash on all Gitlab CI stages (@72bab017c1167b8ab35cef3cc709ff83686eaca4) - Require Bash on all Gitlab CI stages (@72bab017c1167b8ab35cef3cc709ff83686eaca4)
- Add a script to push the README.md into the Docker Hub repository's full_description (@8cb49cbc8253368701d718c2e38017790c78ceca, @ca6128fb96602da71f3b7a560e834d1b7587abac) - Add a script to push the README.md into the Docker Hub repository's full_description (@8cb49cbc8253368701d718c2e38017790c78ceca, @ca6128fb96602da71f3b7a560e834d1b7587abac)
### [1.0.3] - 2019/03/19 ### __[1.0.3](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.3)__ | _2019/03/19_
- Restrict staging pipelines to pushed pipelines - Restrict staging pipelines to pushed pipelines
- Restrict production pipelines to pushed and triggered pipelines - Restrict production pipelines to pushed and triggered pipelines
- Require a build target on triggered production pipelines - Require a build target on triggered production pipelines
### [1.0.2] - 2019/03/18 ### __[1.0.2](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.2)__ | _2019/03/18_
- Fix a minor issue when testing for requested production build. - Fix a minor issue when testing for requested production build.
### [1.0.1] - 2019/03/18 ### __[1.0.1](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.1)__ | _2019/03/18_
- Add failsafe when importing Seafile's APT-key - Add failsafe when importing Seafile's APT-key
- Restrict production build to latest, majors, minors and revisions version, on-demand. - Restrict production build to latest, majors, minors and revisions version, on-demand.
# [1.0.0] - 2019/03/15 # __[1.0.0](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.0.0)__ | _2019/03/15_
- Release to Docker Hub - Release to Docker Hub
# [0.9.2] - 2019/03/15 ### __[0.9.2](https://gitlab.com/flwgns-docker/seafile-client/-/tags/0.9.2)__ | _2019/03/15_
- Test release on GitLab, before Docker Hub - Test release on GitLab, before Docker Hub

View File

@@ -1,66 +0,0 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM debian:buster-slim
# Prevent the packages installation to halt.
ENV DEBIAN_FRONTEND noninteractive
# Create the seafile client user.
ENV UNAME=seafuser
ENV UID=1000
ENV GID=1000
# Copy over the Docker related files.
COPY utils/build/import-seafile-apt-key.sh /
COPY assets/cron/docker-entrypoint.sh /entrypoint.sh
# Safely import Seafile APT key, then install both seafile-cli and supervisord.
RUN mkdir -p /etc/apt/sources.list.d/ && \
apt-get update && \
apt-get install -y gnupg && \
echo "deb http://deb.seadrive.org buster main" \
> /etc/apt/sources.list.d/seafile.list && \
bash /import-seafile-apt-key.sh && \
apt-get remove -y gnupg && \
apt-get autoremove -y && \
apt-get update && \
apt-get install \
-o Dpkg::Options::="--force-confold" \
-y \
seafile-cli \
cron && \
apt-get clean && \
apt-get autoclean \
-o APT::Clean-Installed=true && \
rm \
-rf \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/var/lib/apt/lists/* \
/import-seafile-apt-key.sh && \
mkdir /volume/ && \
echo "seafuser" > /etc/cron.allow && \
echo "*/20 * * * * /bin/bash /home/seafuser/seafile-healthcheck.sh" \
> /var/spool/cron/crontabs/seafuser && \
groupadd -g $GID -o $UNAME && \
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
# Copy over the required files for Seafile/SupervisorD.
COPY assets/cron/seafile-healthcheck.sh /home/seafuser/seafile-healthcheck.sh
COPY assets/cron/seafile-entrypoint.sh /home/seafuser/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

1
Dockerfile Symbolic link
View File

@@ -0,0 +1 @@
assets/cron/Dockerfile

View File

@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 29 June 2007
Copyright (C) 2019 flow.gunso@gmail.com Copyright (C) 2019-2020 flow.gunso@gmail.com
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.

143
README.md
View File

@@ -1,98 +1,97 @@
[![1.2.1 build status](https://gitlab.com/flwgns-docker/seafile-client/badges/1.2.1/pipeline.svg)](https://gitlab.com/flwgns-docker/seafile-client/commits/1.2.1) [![2.0.0 build status](https://gitlab.com/flwgns-docker/seafile-client/badges/2.0.0/pipeline.svg)](https://gitlab.com/flwgns-docker/seafile-client/commits/2.0.0)
[![Docker pulls](https://img.shields.io/docker/pulls/flowgunso/seafile-client.svg)](https://hub.docker.com/r/flowgunso/seafile-client) [![Docker pulls](https://img.shields.io/docker/pulls/flowgunso/seafile-client.svg)](https://hub.docker.com/r/flowgunso/seafile-client)
[![Licensed under GPLv3](https://img.shields.io/badge/License-GPLv3-red.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Licensed under GPLv3](https://img.shields.io/badge/License-GPLv3-red.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![@gitlab.com/flwgns-docker/seafile-client](https://img.shields.io/badge/Source%20code-GitLab-red.svg)](https://gitlab.com/flwgns-docker/seafile-client/) [![@gitlab.com/flwgns-docker/seafile-client](https://img.shields.io/badge/Source%20code-GitLab-red.svg)](https://gitlab.com/flwgns-docker/seafile-client/)
# Available tags **Share a Seafile library as a volume to other containers.**
Weekly stable release are built every Monday at 6AM UTC+2. # Supported tags
Permanent stable releases will not be built again. [`2`, `2.0`, `2.0.0`, `latest`](seafile-client/Dockerfile)
## Weekly stable releases. # Informations
[`1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.1), * Synchronize a single Seafile library, available at the path `/library/'.
[`1.2`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.1), * Password protected librairies are supported.
[`1.2.1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.1), * Two factor authentication is supported.
[`latest`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.1) * Upload and download speeds are configurable.
* SSL certificates are skippable.
## Developmental releases. <!-- -->
[`staging`](https://gitlab.com/flwgns-docker/seafile-client/tree/staging): * Supported tags are rebuilt weekly.
The purpose of this release is to test feature and make them available to anyone. <!-- -->
* Ask questions on [Seafile forum](https://forum.seafile.com/t/docker-client-to-sync-files-with-containers/8573).
# Purpose * Contribute and report issues on [Gitlab](https://gitlab.com/flwgns-docker/seafile-client/).
Docker Seafile Client allow you to sync a Seafile library within a container.
**Essentially, you can share a Seafile library as a volume to other containers**.
## Seafile?
[Seafile is a cloud storage software](https://www.seafile.com/).
# Usage # Usage
The *Seafile* daemon is running as the user `seafuser` from it's directories `~/.seafile/` and `~/.ccnet`. ## Required configuration
__SEAF_SERVER_URL__, __SEAF_USERNAME__, __SEAF_PASSWORD__, __SEAF_LIBRARY_UUID__
Provide your Seafile _server URL_, _username_, _password_ and _library UUID_ to synchronise your library at `/library`, then share it as a volume.
The library is synced at `/volume/`. The `seaf-cli` is ran within the container as the user `seafuser`.
The *Seafile* daemon is managed with *supervisord* since it can't run as a foreground process. ## Optional configurations
The *supervisord* is running from `~/.supervisord/`, the `supervisord.conf`, `supervisord.log` and `supervisord.pid` can be found there. __SEAF_2FA_SECRET__
*supervisord* also manage a shell script, `~/infinite-seaf-cli-start.sh` which stop then start the Seafile daemon every 20 minutes: the synchronisation might not work properly if the Seafile daemon is not restarted from times to times, for an unresolved reason. _Two factor authentication is supported but your secret key must be provided._ That key can be found on your Seafile web interface, only at the 2FA setup, when the QR code is shown. The secret key is embedded in the QR or available as a cookie.
## Examples
You would have to share the path `/volume/` to other containers, with the following approaches: __SEAF_LIBRARY_PASSWORD__
### Docker CLI Password protected librairies can be sync provided with the _password_.
__SEAF_UPLOAD_LIMIT__, __SEAF_DOWNLOAD_LIMIT__
Upload and download speeds are configurable as _absolute bytes_.
__SEAF_SKIP_SSL_CERT__
Skip SSL certificates verifications. _Any string is considered true, omit the variable to set to false_. Enable this if you have synchronization failures regarding SSL certificates.
__UID__, __GID__
Override the _UID_ and _GID_ for volume read/write permissions.
# Examples
## As a Docker command
``` ```
docker run \ docker run \
-e SEAF_SERVER_URL= \ # The URL to your Seafile server. -e SEAF_SERVER_URL=https://seafile.example/
-e SEAF_USERNAME= \ # Your Seafile username. -e SEAF_USERNAME=a_seafile_user
-e SEAF_PASSWORD= \ # Your Seafile password -e SEAF_PASSWORD=SoMePaSSWoRD
-e SEAF_LIBRARY_UUID= \ # The Seafile library UUID you want to sync with. -e SEAF_LIBRARY_UUID=an-hexadecimal-library-uuid
-e UID= \ # Default is 1000. -v path/to/shared/volume:/library \
-e GID= \ # Default is 1000.
-v your/shared/volume:/volume \
flowgunso/seafile-client:latest flowgunso/seafile-client:latest
``` ```
### docker-compose ## As a Docker Compose
```yaml ```yaml
version: "3.4"
services: services:
seafile-client: seafile-client:
image: flowgunso/seafile-client:latest image: flowgunso/seafile-client:latest
restart: on-failure
volumes: volumes:
- your_shared_volume:/volume - shared_volume:/library
environment: environment:
- SEAF_SERVER_URL= # The URL to your Seafile server. SEAF_SERVER_URL: "https://seafile.example/"
- SEAF_USERNAME= # Your Seafile username. SEAF_USERNAME: "a_seafile_user"
- SEAF_PASSWORD= # Your Seafile password. SEAF_PASSWORD: "SoMePaSSWoRD"
- SEAF_LIBRARY_UUID= # The Seafile library UUID you want to sync with. SEAF_LIBRARY_UUID: "an-hexadecimal-library-uuid"
- UID= # Default is 1000.
- GID= # Default is 1000.
volumes: volumes:
your_shared_volume: shared_volume:
``` ```
## With all optional configurations
```yaml
services:
seafile-client:
image: flowgunso/seafile-client:latest
volumes:
- shared_volume:/library
environment:
SEAF_SERVER_URL: "https://seafile.example/"
SEAF_USERNAME: "a_seafile_user"
SEAF_PASSWORD: "SoMePaSSWoRD"
SEAF_LIBRARY_UUID: "an-hexadecimal-library-uuid"
SEAF_2FA_SECRET: "JBSWY3DPEHPK3PXPIXDAUMXEDOXIUCDXWC32CS"
SEAF_LIBRARY_PASSWORD: "LiBRaRyPaSSWoRD"
SEAF_UPLOAD_LIMIT: "1000000"
SEAF_DOWNLOAD_LIMIT: "1000000"
SEAF_SKIP_SSL_CERT: "true"
# Environment variables volumes:
The following environment variable are available. shared_volume:
```
## Seafile Or use the [docker-compose.yml](documentations/docker-compose.yml) template.
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/seafile-client](https://gitlab.com/flwgns-docker/seafile-client/).

View File

@@ -1,56 +0,0 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM debian:jessie-slim
# Prevent the packages installation to halt.
ENV DEBIAN_FRONTEND noninteractive
# Specify the user running Seafile.
ENV UNAME=seafuser
ENV UID=1000
ENV GID=1000
# Copy over the Docker related files.
COPY utils/build/import-seafile-apt-key.sh /
COPY assets/bash/docker-entrypoint.sh /entrypoint.sh
# Safely import Seafile APT key, then install both seafile-cli and supervisord.
RUN mkdir -p /etc/apt/sources.list.d/ ;\
echo "deb http://deb.seadrive.org jessie main" \
> /etc/apt/sources.list.d/seafile.list ;\
/bin/bash /import-seafile-apt-key.sh ;\
apt-get update ;\
apt-get install \
-o Dpkg::Options::="--force-confold" \
-y seafile-cli ;\
apt-get clean ;\
apt-get autoclean \
-o APT::Clean-Installed=true ;\
rm \
-f \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/import-seafile-apt-key.sh ;\
mkdir /volume ;\
groupadd -g $GID -o $UNAME ;\
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
# Copy over the required files for Seafile/SupervisorD.
COPY assets/bash/seafile-healthcheck.sh /home/seafuser/
COPY assets/bash/seafile-entrypoint.sh /home/seafuser/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View File

@@ -1,54 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Check mandatory Seafile configuration have been properly set.
if [ -z $SEAF_SERVER_URL ]; then echo "The \$SEAF_SERVER_URL was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_USERNAME ]; then echo "The \$SEAF_USERNAME was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_PASSWORD ]; then echo "The \$SEAF_PASSWORD was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID was not defined. Stopping container..."; exit 1; fi
# Update the user ID, if the $UID changed.
if [ "$UID" != "1000" ]; then
usermod -u $UID $UNAME
# What if the $UID already exists ?
fi
# Change the group, if the $GID changed.
if [ "$GID" != "1000" ]; then
getent group | grep ":$GID:" >/dev/null
if [ $? -eq 0 ]; then
usermod -g $GID -G 1000 $UNAME
else
groupmod -g $GID $UNAME
fi
fi
# Set the files ownership.
chown $UID.$GID -R /home/seafuser/seafile-healthcheck.sh
chown $UID.$GID -R /home/seafuser/entrypoint.sh
chown $UID.$GID -R /volume
# Run the Seafile client as the container user.
su - $UNAME << EO
export SEAF_SERVER_URL=$SEAF_SERVER_URL
export SEAF_USERNAME=$SEAF_USERNAME
export SEAF_PASSWORD=$SEAF_PASSWORD
export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID
export UNAME=$UNAME
/bin/bash /home/seafuser/entrypoint.sh
EO

View File

@@ -1,47 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# `seaf-cli status` output csv-like information with tabulates as separators and columns named in comment lines.
# The Seafile client should not be restarted while some statuses are occuring, such as "downloading" or "committing".
#
# This script grabs the output while ignoring the comments to iterate over the informations set to their columns,
# then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't.
seaf=/usr/bin/seaf-cli
dont_restart_on=("downloading" "committing")
restart=true
sleep 10s
while true; do
while IFS=$'\t' read -r name status progress; do
if [ $status ]; then
for dont_restart_on_status in "${dont_restart_on[@]}"; do
if [ "$status" == "$dont_restart_on_status" ]; then
restart=false; break; break
fi
done
fi
done < <($seaf status | grep -v "^#")
if $restart; then
$seaf stop
$seaf start
fi
sleep 10m
done

View File

@@ -1,61 +0,0 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM debian:jessie-slim
# Prevent the packages installation to halt.
ENV DEBIAN_FRONTEND noninteractive
# Create the seafile client user.
ENV UNAME=seafuser
ENV UID=1000
ENV GID=1000
# Copy over the Docker related files.
COPY utils/build/import-seafile-apt-key.sh /
COPY assets/cron/docker-entrypoint.sh /entrypoint.sh
# Safely import Seafile APT key, then install both seafile-cli and supervisord.
RUN mkdir -p /etc/apt/sources.list.d/ ;\
echo "deb http://deb.seadrive.org jessie main" \
> /etc/apt/sources.list.d/seafile.list ;\
bash /import-seafile-apt-key.sh ;\
apt-get update ;\
apt-get install \
-o Dpkg::Options::="--force-confold" \
-y \
seafile-cli \
cron ;\
apt-get clean ;\
apt-get autoclean \
-o APT::Clean-Installed=true ;\
rm \
-f \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/import-seafile-apt-key.sh ;\
mkdir /volume/ ;\
echo "seafuser" > /etc/cron.allow ;\
echo "*/20 * * * * /bin/bash /home/seafuser/seafile-healthcheck.sh" \
> /var/spool/cron/crontabs/seafuser ;\
groupadd -g $GID -o $UNAME ;\
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
# Copy over the required files for Seafile/SupervisorD.
COPY assets/cron/seafile-healthcheck.sh /home/seafuser/seafile-healthcheck.sh
COPY assets/cron/seafile-entrypoint.sh /home/seafuser/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View File

@@ -1 +0,0 @@
deb http://deb.seadrive.org jessie main

View File

@@ -1,58 +0,0 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM debian:jessie-slim
# Prevent the packages installation to halt.
ENV DEBIAN_FRONTEND noninteractive
# Specify the user running Seafile.
ENV UNAME=seafuser
ENV UID=1000
ENV GID=1000
# Copy over the Docker related files.
COPY utils/build/import-seafile-apt-key.sh /
COPY assets/supervisord/dockerentrypoint.sh /entrypoint.sh
# Safely import Seafile APT key, then install both seafile-cli and supervisord.
RUN mkdir -p /etc/apt/sources.list.d/ ;\
echo "deb http://deb.seadrive.org jessie main" \
> /etc/apt/sources.list.d/seafile.list ;\
/bin/bash /import-seafile-apt-key.sh ;\
apt-get update ;\
apt-get install \
-o Dpkg::Options::="--force-confold" \
-y \
seafile-cli \
supervisor ;\
apt-get clean ;\
apt-get autoclean \
-o APT::Clean-Installed=true ;\
rm \
-f \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/import-seafile-apt-key.sh ;\
mkdir /volume ;\
groupadd -g $GID -o $UNAME ;\
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME
# Copy over the required files for Seafile/SupervisorD.
COPY assets/supervisord/supervisord.conf assets/supervisord/seafile-healthcheck.sh /home/seafuser/
COPY assets/supervisord/seafile-entrypoint.sh /home/seafuser/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View File

@@ -1,55 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Check mandatory Seafile configuration have been properly set.
if [ -z $SEAF_SERVER_URL ]; then echo "The \$SEAF_SERVER_URL was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_USERNAME ]; then echo "The \$SEAF_USERNAME was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_PASSWORD ]; then echo "The \$SEAF_PASSWORD was not defined. Stopping container..."; exit 1; fi
if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID was not defined. Stopping container..."; exit 1; fi
# Update the user ID, if the $UID changed.
if [ "$UID" != "1000" ]; then
usermod -u $UID $UNAME
# TODO: What if the $UID already exists ?
fi
# Change the group, if the $GID changed.
if [ "$GID" != "1000" ]; then
getent group | grep ":$GID:" >/dev/null
if [ $? -eq 0 ]; then
usermod -g $GID -G 1000 $UNAME
else
groupmod -g $GID $UNAME
fi
fi
# Set the files ownership.
chown $UID.$GID -R /home/seafuser/supervisord.conf
chown $UID.$GID -R /home/seafuser/seafile-healthcheck.sh
chown $UID.$GID -R /home/seafuser/entrypoint.sh
chown $UID.$GID -R /volume
# Run the Seafile client as the container user.
su - $UNAME << EO
export SEAF_SERVER_URL=$SEAF_SERVER_URL
export SEAF_USERNAME=$SEAF_USERNAME
export SEAF_PASSWORD=$SEAF_PASSWORD
export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID
export UNAME=$UNAME
/bin/bash /home/seafuser/entrypoint.sh
EO

View File

@@ -1,47 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# `seaf-cli status` output csv-like information with tabulates as separators and columns named in comment lines.
# The Seafile client should not be restarted while some statuses are occuring, such as "downloading" or "committing".
#
# This script grabs the output while ignoring the comments to iterate over the informations set to their columns,
# then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't.
seaf=/usr/bin/seaf-cli
dont_restart_on=("downloading" "committing")
restart=true
sleep 10s
while true; do
while IFS=$'\t' read -r name status progress; do
if [ $status ]; then
for dont_restart_on_status in "${dont_restart_on[@]}"; do
if [ "$status" == "$dont_restart_on_status" ]; then
restart=false; break; break
fi
done
fi
done < <($seaf status | grep -v "^#")
if $restart; then
$seaf stop
$seaf start
fi
sleep 10m
done

View File

@@ -1,18 +0,0 @@
version: "3.4"
services:
seafile-client:
image: flowgunso/seafile-client:latest
restart: on-failure
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:

View File

@@ -0,0 +1,20 @@
version: "3.4"
services:
seafile-client:
image: flowgunso/seafile-client:latest
volumes:
- shared_volume:/library
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.
# SEAF_LIBRARY_PASSWORD: "" # The Seafile library password, if required.
# SEAF_SKIP_SSL_CERT: "true" # Any string is true, omit to set to false.
# SEAF_2FA_SECRET: "" # The 2FA secret key available at Seafile 2FA setup.
# UID: "" # Default is 1000.
# GID: "" # Default is 1000.
volumes:
shared_volume:

69
seafile-client/Dockerfile Normal file
View File

@@ -0,0 +1,69 @@
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019-2020, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM debian:buster-slim
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL maintainer="flow.gunso@gmail.com" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Seafile Docker client" \
org.label-schema.description="Sync Seafile librairies within Docker containers." \
org.label-schema.url=$CI_PROJECT_URL \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$CI_PROJECT_URL \
org.label-schema.vendor="flow.gunso@gmail.com" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0"
# Install seaf-cli and oathtool, prepare the user.
ENV DEBIAN_FRONTEND=noninteractive
ENV UNAME=seafuser UID=1000 GID=1000
COPY import-seafile-apt-key.sh /
RUN apt-get update && apt-get install -y gnupg && \
mkdir -p /etc/apt/sources.list.d/ && \
echo "deb http://deb.seadrive.org buster main" > /etc/apt/sources.list.d/seafile.list && \
bash /import-seafile-apt-key.sh && \
apt-get purge --yes gnupg && apt-get autoremove --yes && \
apt-get update && apt-get install \
--no-install-recommends \
--yes \
seafile-cli \
oathtool && \
apt-get clean && apt-get autoclean && \
rm -rf \
/var/log/fsck/*.log \
/var/log/apt/*.log \
/var/cache/debconf/*.dat-old \
/var/lib/apt/lists/* \
/import-seafile-apt-key.sh && \
mkdir /library/ && \
groupadd -g $GID -o $UNAME && \
useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME && \
mkdir /home/$UNAME/.seafile && \
chown $UNAME:$GID /home/$UNAME/.seafile
# Copy over the assets.
COPY docker-entrypoint.sh /entrypoint.sh
COPY docker-healthcheck.sh /healthcheck.sh
COPY seafile-entrypoint.sh /home/seafuser/entrypoint.sh
#COPY seafile-healthcheck.sh /home/seafuser/healthcheck.sh
COPY tests /tests
ENTRYPOINT ["/bin/bash", "--"]
CMD ["/entrypoint.sh"]
HEALTHCHECK --start-period=20s --retries=1 CMD ["su", "-", "${UNAME}", "-c", "/healthcheck.sh"]

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -16,17 +16,25 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
function fail_with_message {
echo "$1"
echo "Exiting container."
exit 1
}
# Check mandatory Seafile configuration have been properly set. # Check mandatory Seafile configuration have been properly set.
if [ -z $SEAF_SERVER_URL ]; then echo "The \$SEAF_SERVER_URL was not defined. Stopping container..."; exit 1; fi [[ -z "$SEAF_SERVER_URL" ]] && fail_with_message "The \$SEAF_SERVER_URL is not defined."
if [ -z $SEAF_USERNAME ]; then echo "The \$SEAF_USERNAME was not defined. Stopping container..."; exit 1; fi [[ -z "$SEAF_USERNAME" ]] && fail_with_message "The \$SEAF_USERNAME is not defined."
if [ -z $SEAF_PASSWORD ]; then echo "The \$SEAF_PASSWORD was not defined. Stopping container..."; exit 1; fi [[ -z "$SEAF_PASSWORD" ]] && fail_with_message "The \$SEAF_PASSWORD is not defined."
if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID was not defined. Stopping container..."; exit 1; fi [[ -z "$SEAF_LIBRARY_UUID" ]] && fail_with_message "The \$SEAF_LIBRARY_UUID is not defined."
[[ -n "$SEAF_UPLOAD_LIMIT" && $SEAF_UPLOAD_LIMIT =~ ^[0-9]+$ && "$SEAF_UPLOAD_LIMIT" -gt 0 ]] && \
fail_with_message "The \$SEAF_UPLOAD_LIMIT is not an integer greater than 0."
[[ -n "$SEAF_DOWNLOAD_LIMIT" && $SEAF_DOWNLOAD_LIMIT =~ ^[0-9]+$ && "$SEAF_DOWNLOAD_LIMIT" -gt 0 ]] && \
fail_with_message "The \$SEAF_DOWNLOAD_LIMIT is not an integer greater than 0."
# Update the user ID, if the $UID changed. # Update the user ID, if the $UID changed.
if [ "$UID" != "1000" ]; then # TODO: What if the $UID already exists ?
usermod -u $UID $UNAME [[ "$UID" != "1000" ]] && usermod -u $UID $UNAME
# What if the $UID already exists ?
fi
# Change the group, if the $GID changed. # Change the group, if the $GID changed.
if [ "$GID" != "1000" ]; then if [ "$GID" != "1000" ]; then
@@ -39,7 +47,7 @@ if [ "$GID" != "1000" ]; then
fi fi
# Set the files ownership. # Set the files ownership.
chown $UID.$GID /home/seafuser/seafile-healthcheck.sh chown $UID.$GID /home/seafuser/healthcheck.sh
chown $UID.$GID /home/seafuser/entrypoint.sh chown $UID.$GID /home/seafuser/entrypoint.sh
chown $UID.$GID -R /volume chown $UID.$GID -R /volume
@@ -49,8 +57,10 @@ su - $UNAME << EO
export SEAF_USERNAME=$SEAF_USERNAME export SEAF_USERNAME=$SEAF_USERNAME
export SEAF_PASSWORD=$SEAF_PASSWORD export SEAF_PASSWORD=$SEAF_PASSWORD
export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID
export UNAME=$UNAME [[ "$SEAF_SKIP_SSL_CERT" ]] && export SEAF_SKIP_SSL_CERT=$SEAF_SKIP_SSL_CERT
[[ "$SEAF_UPLOAD_LIMIT" ]] && export SEAF_UPLOAD_LIMIT=$SEAF_UPLOAD_LIMIT
[[ "$SEAF_DOWNLOAD_LIMIT" ]] && export SEAF_DOWNLOAD_LIMIT=$SEAF_DOWNLOAD_LIMIT
[[ "$SEAF_2FA_SECRET" ]] && export SEAF_2FA_SECRET=$SEAF_2FA_SECRET
[[ "$SEAF_LIBRARY_PASSWORD" ]] && export SEAF_LIBRARY_PASSWORD=$SEAF_LIBRARY_PASSWORD
/bin/bash /home/seafuser/entrypoint.sh /bin/bash /home/seafuser/entrypoint.sh
EO EO
cron -f

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -16,23 +16,13 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# Define variable shortcuts for readability purposes. # Grab the status of the active repos then return as healthy/unhealthy
seafile_ini=~/.ccnet/seafile.ini # depending the healthy statuses.
seafile_sock=~/.seafile/seafile-data/seafile.sock
# Prepare the directories. healthy_statuses=("downloading" "waiting for sync", "uploading", "downloading files", "downloading file list")
mkdir ~/.seafile while IFS=$'\t' read -r name status; do
for healthy_status in "${healthy_statuses[@]}"; do
# Safely initialise the Seafile client. if [[ "$status" == "$healthy" ]]; then exit 0; fi
/usr/bin/seaf-cli init -d ~/.seafile done
while [ ! -f $seafile_ini ]; do sleep 1; done exit 1
done < <(seaf-cli status | grep -v "^#")
# Safely start the Seafile daemon.
/usr/bin/seaf-cli start
while [ ! -S $seafile_sock ]; do sleep 1; done
# Start the synchronisation.
/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume
# Run the infinite Seafile restart.
source ~/seafile-healthcheck.sh

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -16,27 +16,30 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# Define variable shortcuts for readability purposes.
seafile_ini=~/.ccnet/seafile.ini
seafile_sock=~/.seafile/seafile-data/seafile.sock
supervisord_conf=~/supervisord.conf
supervisord_pid=~/.supervisord/supervisord.pid
supervisord_log=~/.supervisord/supervisord.log
# Prepare the directories.
mkdir ~/.seafile
mkdir ~/.supervisord
# Safely initialise the Seafile client. # Safely initialise the Seafile client.
seafile_ini=~/.ccnet/seafile.ini
/usr/bin/seaf-cli init -d ~/.seafile /usr/bin/seaf-cli init -d ~/.seafile
while [ ! -f $seafile_ini ]; do sleep 1; done while [ ! -f $seafile_ini ]; do sleep 1; done
# Safely start the Seafile daemon. # Safely start the Seafile daemon.
seafile_sock=~/.seafile/seafile-data/seafile.sock
/usr/bin/seaf-cli start /usr/bin/seaf-cli start
while [ ! -S $seafile_sock ]; do sleep 1; done while [ ! -S $seafile_sock ]; do sleep 1; done
# Start the synchronisation. # Set the disable_verify_certificate key to true only if the environment variable exists.
/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume [[ "$SEAF_SKIP_SSL_CERT" ]] && seaf-cli config -k disable_verify_certificate -v true
# Start the supervisord. # Set the upload/download limits
/usr/bin/supervisord -u $UNAME -c $supervisord_conf -j $supervisord_pid -l $supervisord_log [[ "$SEAF_UPLOAD_LIMIT" ]] && seaf-cli config -k upload_limit -v $SEAF_UPLOAD_LIMIT
[[ "$SEAF_DOWNLOAD_LIMIT" ]] && seaf-cli config -k download_limit -v $SEAF_DOWNLOAD_LIMIT
# Build the seaf-cli sync command.
cmd="seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /library"
[[ "$SEAF_2FA_SECRET" ]] && cmd+=" -a $(oathtool --base32 --totp $SEAF_2FA_SECRET)"
[[ "$SEAF_LIBRARY_PASSWORD" ]] && cmd+=" -e $SEAF_LIBRARY_PASSWORD"
# Run it.
if ! eval $cmd; then echo "Failed to synchronize."; exit 1; fi
# Continously print the log.
tail -f ~/.ccnet/logs/seafile.log

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by

25
utils/publish/staging.sh → tests/test_binaries.sh Executable file → Normal file
View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -16,15 +16,18 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# Restrict to pipeline triggered by pushes. failures=()
if [ $CI_PIPELINE_SOURCE != "push" ]; then binaries=(seaf-cli oathtool)
echo "This must be only ran from pushes."
for binary in "${binaries[@]}"; do
if ! [ -x "$(command -v $binary)" ]; then
echo "$binary was not found"
failures+=($binary)
else
echo "$binary was found"
fi
done
if [ ${#failures[@]} -ne 0 ]; then
exit 1 exit 1
fi fi
# Login with Docker Registry.
echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin
# Build and push as staging.
docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging .
docker push index.docker.io/$CI_REGISTRY_IMAGE:staging

View File

@@ -1,34 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Restrict to pipeline triggered by pushes.
if [ $CI_PIPELINE_SOURCE != "push" ]; then
echo "This must be only ran from pushes."
exit 1
fi
# Login with Docker Registry.
echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin
# Build and push as staging.
docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord -f assets/supervisord/Dockerfile .
docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-cron -f assets/cron/Dockerfile .
docker build -t index.docker.io/$CI_REGISTRY_IMAGE:staging-bash -f assets/bash/Dockerfile .
docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-supervisord
docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-cron
docker push index.docker.io/$CI_REGISTRY_IMAGE:staging-bash

View File

@@ -1,70 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Restrict production build to tag matching MAJOR.MINOR.REVISION.
if ! [[ "$CI_COMMIT_TAG" =~ ^[0-9]+[.][0-9]+[.][0-9]+$ ]]; then
echo "Version number must match major.minor.revision!"
exit 1
fi
# When this stage is ran from 'push', the build target is BUILD_LATEST.
# When this stage is ran from 'trigger', the build target must be provided.
# Otherwise, stop the stage.
if [ $CI_PIPELINE_SOURCE == "push" ]; then
BUILD_LATEST=true
elif [ $CI_PIPELINE_SOURCE == "trigger" ]; then
if [ -z $BUILD_LATEST ] && \
[ -z $BUILD_MAJOR ] && \
[ -z $BUILD_MINOR ] && \
[ -z $BUILD_REVISION ]; then
echo "You must provide build targets to this stage when ran from Pipeline Triggers."
exit 1
fi
else
echo "This stage is restricted to 'push' or 'trigger' Pipeline sources."
exit 1
fi
# Cascade the builds by inheritance.
if [ $BUILD_LATEST ]; then BUILD_MAJOR=true; BUILD_MINOR=true; BUILD_REVISION=true; fi
if [ $BUILD_MAJOR ]; then BUILD_MINOR=true; BUILD_REVISION=true; fi
if [ $BUILD_MINOR ]; then BUILD_REVISION=true; fi
# Define MAJOR, MINOR and REVISION version numbers.
MAJOR_NUMBER=$(echo "$CI_COMMIT_TAG" | awk -F \. {'print $1'})
MINOR_NUMBER=$(echo "$CI_COMMIT_TAG" | awk -F \. {'print $2'})
REVISION_NUMBER=$(echo "$CI_COMMIT_TAG" | awk -F \. {'print $3'})
MAJOR=$MAJOR_NUMBER
MINOR=$MAJOR.$MINOR_NUMBER
REVISION=$MINOR.$REVISION_NUMBER
# Always build with all tags, there's a single build anyway.
docker build \
-t index.docker.io/$CI_REGISTRY_IMAGE:latest \
-t index.docker.io/$CI_REGISTRY_IMAGE:$MAJOR \
-t index.docker.io/$CI_REGISTRY_IMAGE:$MINOR \
-t index.docker.io/$CI_REGISTRY_IMAGE:$REVISION .
# Login with Docker Registry.
echo $CI_REGISTRY_BOT_PASSWORD | docker login -u $CI_REGISTRY_BOT_USERNAME docker.io --password-stdin
# Only push requested builds.
if [ $BUILD_LATEST ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:latest; fi
if [ $BUILD_MAJOR ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:$MAJOR; fi
if [ $BUILD_MINOR ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:$MINOR; fi
if [ $BUILD_REVISION ]; then docker push index.docker.io/$CI_REGISTRY_IMAGE:$REVISION; fi