From 9af5f1bde94a5ec99a71051bdc9cd0373a1fc18c Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 30 Dec 2019 09:55:52 +0100 Subject: [PATCH 01/42] Move changes from the project's Dockerfile here --- assets/cron/Dockerfile | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/assets/cron/Dockerfile b/assets/cron/Dockerfile index 3272c7f..ff1b902 100644 --- a/assets/cron/Dockerfile +++ b/assets/cron/Dockerfile @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -FROM debian:jessie-slim +FROM debian:buster-slim # Prevent the packages installation to halt. ENV DEBIAN_FRONTEND noninteractive @@ -28,30 +28,35 @@ 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 ;\ +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 ;\ + cron && \ + apt-get clean && \ apt-get autoclean \ - -o APT::Clean-Installed=true ;\ + -o APT::Clean-Installed=true && \ rm \ - -f \ + -rf \ /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 ;\ + /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 ;\ + > /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. From 06f184d1ad42f1ff2a843e8180110fdeab76595d Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 30 Dec 2019 09:56:32 +0100 Subject: [PATCH 02/42] Add an envvar to skip ssl certificates that default to false --- assets/cron/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/cron/Dockerfile b/assets/cron/Dockerfile index ff1b902..a6eb293 100644 --- a/assets/cron/Dockerfile +++ b/assets/cron/Dockerfile @@ -22,6 +22,7 @@ ENV DEBIAN_FRONTEND noninteractive ENV UNAME=seafuser ENV UID=1000 ENV GID=1000 +ENV SEAF_SKIP_SSL_CERT=1 # Copy over the Docker related files. COPY utils/build/import-seafile-apt-key.sh / From 8267535a9725905a8f21aa16101a28fc2c4e78ee Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 30 Dec 2019 09:57:30 +0100 Subject: [PATCH 03/42] Remove hard file --- Dockerfile | 66 ------------------------------------------------------ 1 file changed, 66 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ff1b902..0000000 --- a/Dockerfile +++ /dev/null @@ -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 . - -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"] From 8e33c7431e2933f427ec79742784adad40c28eca Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 30 Dec 2019 09:58:03 +0100 Subject: [PATCH 04/42] Create as a symlink to asset/cron/Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) create mode 120000 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 120000 index 0000000..842615a --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +assets/cron/Dockerfile \ No newline at end of file From 9f526467fef309ace069748abd90dd90547772c6 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 30 Dec 2019 10:09:06 +0100 Subject: [PATCH 05/42] Implement upload/download limits, disable_verify_certificates config keys --- assets/cron/docker-entrypoint.sh | 35 +++++++++++++++++++++++++++---- assets/cron/seafile-entrypoint.sh | 7 +++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/assets/cron/docker-entrypoint.sh b/assets/cron/docker-entrypoint.sh index 901e7d4..7849471 100644 --- a/assets/cron/docker-entrypoint.sh +++ b/assets/cron/docker-entrypoint.sh @@ -17,10 +17,34 @@ # along with this program. If not, see . # 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 +if [ -z $SEAF_SERVER_URL ]; then + echo "The \$SEAF_SERVER_URL is not defined. Stopping container..." + exit 1 +fi +if [ -z $SEAF_USERNAME ]; then + echo "The \$SEAF_USERNAME is not defined. Stopping container..." + exit 1 +fi +if [ -z $SEAF_PASSWORD ]; then + echo "The \$SEAF_PASSWORD is not defined. Stopping container..." + exit 1 +fi +if [ -z $SEAF_LIBRARY_UUID ]; then + echo "The \$SEAF_LIBRARY_UUID is not defined. Stopping container..." + exit 1 +fi +if [ -n "$SEAF_UPLOAD_LIMIT" ] +&& [[ $SEAF_UPLOAD_LIMIT =~ ^[0-9]+$ ]] +&& [ "$SEAF_UPLOAD_LIMIT" -gt 0 ]; then + echo "The \$SEAF_UPLOAD_LIMIT is not an integer greater than 0. Stopping container..." + exit 1 +fi +if [ -n "$SEAF_DOWNLOAD_LIMIT" ] +&& [[ $SEAF_DOWNLOAD_LIMIT =~ ^[0-9]+$ ]] +&& [ "$SEAF_DOWNLOAD_LIMIT" -gt 0 ]; then + echo "The \$SEAF_DOWNLOAD_LIMIT is not an integer greater than 0. Stopping container..." + exit 1 +fi # Update the user ID, if the $UID changed. if [ "$UID" != "1000" ]; then @@ -49,6 +73,9 @@ su - $UNAME << EO export SEAF_USERNAME=$SEAF_USERNAME export SEAF_PASSWORD=$SEAF_PASSWORD export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID + export SEAF_SKIP_SSL_CERT=$SEAF_SKIP_SSL_CERT + test -n "$SEAF_UPLOAD_LIMIT" && export SEAF_UPLOAD_LIMIT=$SEAF_UPLOAD_LIMIT + test -n "$SEAF_DOWNLOAD_LIMIT" && export SEAF_DOWNLOAD_LIMIT=$SEAF_DOWNLOAD_LIMIT export UNAME=$UNAME /bin/bash /home/seafuser/entrypoint.sh EO diff --git a/assets/cron/seafile-entrypoint.sh b/assets/cron/seafile-entrypoint.sh index 2a2baec..dbf22e3 100644 --- a/assets/cron/seafile-entrypoint.sh +++ b/assets/cron/seafile-entrypoint.sh @@ -31,5 +31,12 @@ while [ ! -f $seafile_ini ]; do sleep 1; done /usr/bin/seaf-cli start while [ ! -S $seafile_sock ]; do sleep 1; done +# Set the disable_verify_certificate key to true only if the environment variable is true. +test "$SEAF_SKIP_SSL_CERT" = true && seaf-cli config -k disable_verify_certificate -v true + +# Set the upload/download limits +test -n "$SEAF_UPLOAD_LIMIT" && seaf-cli config -k upload_limit -v $SEAF_UPLOAD_LIMIT +test -n "$SEAF_DOWNLOAD_LIMIT" && seaf-cli config -k download_limit -v $SEAF_DOWNLOAD_LIMIT + # Start the synchronisation. /usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume \ No newline at end of file From 67ecaa91b5cb60a647ee77453705563757385e01 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Sat, 4 Jan 2020 10:03:23 +0100 Subject: [PATCH 06/42] Remove supervisord and bash versions --- assets/bash/Dockerfile | 56 --------------- assets/bash/docker-entrypoint.sh | 54 -------------- assets/bash/seafile-entrypoint.sh | 38 ---------- assets/bash/seafile-healthcheck.sh | 47 ------------- assets/seafile.list | 1 - assets/supervisord/Dockerfile | 58 --------------- assets/supervisord/docker-entrypoint.sh | 55 --------------- assets/supervisord/seafile-entrypoint.sh | 42 ----------- assets/supervisord/seafile-healthcheck.sh | 47 ------------- assets/supervisord/supervisord.conf | 30 -------- utils/build/import-seafile-apt-key.sh | 27 ------- utils/publish/feature--cron-or-supervisord.sh | 34 --------- utils/publish/production.sh | 70 ------------------- utils/publish/staging.sh | 30 -------- .../update-docker-hub-full-description.sh | 46 ------------ 15 files changed, 635 deletions(-) delete mode 100644 assets/bash/Dockerfile delete mode 100644 assets/bash/docker-entrypoint.sh delete mode 100644 assets/bash/seafile-entrypoint.sh delete mode 100755 assets/bash/seafile-healthcheck.sh delete mode 100644 assets/seafile.list delete mode 100644 assets/supervisord/Dockerfile delete mode 100644 assets/supervisord/docker-entrypoint.sh delete mode 100644 assets/supervisord/seafile-entrypoint.sh delete mode 100755 assets/supervisord/seafile-healthcheck.sh delete mode 100644 assets/supervisord/supervisord.conf delete mode 100644 utils/build/import-seafile-apt-key.sh delete mode 100755 utils/publish/feature--cron-or-supervisord.sh delete mode 100755 utils/publish/production.sh delete mode 100755 utils/publish/staging.sh delete mode 100644 utils/publish/update-docker-hub-full-description.sh diff --git a/assets/bash/Dockerfile b/assets/bash/Dockerfile deleted file mode 100644 index 81d93a6..0000000 --- a/assets/bash/Dockerfile +++ /dev/null @@ -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 . - -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"] diff --git a/assets/bash/docker-entrypoint.sh b/assets/bash/docker-entrypoint.sh deleted file mode 100644 index c2cf920..0000000 --- a/assets/bash/docker-entrypoint.sh +++ /dev/null @@ -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 . - -# 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 \ No newline at end of file diff --git a/assets/bash/seafile-entrypoint.sh b/assets/bash/seafile-entrypoint.sh deleted file mode 100644 index a029c5b..0000000 --- a/assets/bash/seafile-entrypoint.sh +++ /dev/null @@ -1,38 +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 . - -# Define variable shortcuts for readability purposes. -seafile_ini=~/.ccnet/seafile.ini -seafile_sock=~/.seafile/seafile-data/seafile.sock - -# Prepare the directories. -mkdir ~/.seafile - -# Safely initialise the Seafile client. -/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 - -# 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 diff --git a/assets/bash/seafile-healthcheck.sh b/assets/bash/seafile-healthcheck.sh deleted file mode 100755 index 9b05e63..0000000 --- a/assets/bash/seafile-healthcheck.sh +++ /dev/null @@ -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 . - -# `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 \ No newline at end of file diff --git a/assets/seafile.list b/assets/seafile.list deleted file mode 100644 index 11f6d09..0000000 --- a/assets/seafile.list +++ /dev/null @@ -1 +0,0 @@ -deb http://deb.seadrive.org jessie main \ No newline at end of file diff --git a/assets/supervisord/Dockerfile b/assets/supervisord/Dockerfile deleted file mode 100644 index bf66fc7..0000000 --- a/assets/supervisord/Dockerfile +++ /dev/null @@ -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 . - -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"] diff --git a/assets/supervisord/docker-entrypoint.sh b/assets/supervisord/docker-entrypoint.sh deleted file mode 100644 index 0fef05e..0000000 --- a/assets/supervisord/docker-entrypoint.sh +++ /dev/null @@ -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 . - -# 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 \ No newline at end of file diff --git a/assets/supervisord/seafile-entrypoint.sh b/assets/supervisord/seafile-entrypoint.sh deleted file mode 100644 index e603906..0000000 --- a/assets/supervisord/seafile-entrypoint.sh +++ /dev/null @@ -1,42 +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 . - -# 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. -/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 - -# 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 diff --git a/assets/supervisord/seafile-healthcheck.sh b/assets/supervisord/seafile-healthcheck.sh deleted file mode 100755 index 9b05e63..0000000 --- a/assets/supervisord/seafile-healthcheck.sh +++ /dev/null @@ -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 . - -# `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 \ No newline at end of file diff --git a/assets/supervisord/supervisord.conf b/assets/supervisord/supervisord.conf deleted file mode 100644 index 2139015..0000000 --- a/assets/supervisord/supervisord.conf +++ /dev/null @@ -1,30 +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 . - -# 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 /home/seafuser/seafile-healthcheck.sh -process_name=%(program_name)s -numprocs=1 -autostart=true diff --git a/utils/build/import-seafile-apt-key.sh b/utils/build/import-seafile-apt-key.sh deleted file mode 100644 index 4818945..0000000 --- a/utils/build/import-seafile-apt-key.sh +++ /dev/null @@ -1,27 +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 . - -not_imported=true -while $not_imported; do - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8756C4F765C9AC3CB6B85D62379CE192D401AB61 - if [ $? -eq 0 ]; then - not_imported=false - else - sleep 5 - fi -done \ No newline at end of file diff --git a/utils/publish/feature--cron-or-supervisord.sh b/utils/publish/feature--cron-or-supervisord.sh deleted file mode 100755 index 59446dc..0000000 --- a/utils/publish/feature--cron-or-supervisord.sh +++ /dev/null @@ -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 . - -# 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 diff --git a/utils/publish/production.sh b/utils/publish/production.sh deleted file mode 100755 index 8c8d48e..0000000 --- a/utils/publish/production.sh +++ /dev/null @@ -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 . - -# 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 \ No newline at end of file diff --git a/utils/publish/staging.sh b/utils/publish/staging.sh deleted file mode 100755 index ba28fcf..0000000 --- a/utils/publish/staging.sh +++ /dev/null @@ -1,30 +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 . - -# 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 . -docker push index.docker.io/$CI_REGISTRY_IMAGE:staging \ No newline at end of file diff --git a/utils/publish/update-docker-hub-full-description.sh b/utils/publish/update-docker-hub-full-description.sh deleted file mode 100644 index 670eb53..0000000 --- a/utils/publish/update-docker-hub-full-description.sh +++ /dev/null @@ -1,46 +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 . - -# Based upon https://gist.github.com/jlhawn/8f218e7c0b14c941c41f -# and https://github.com/moikot/golang-dep/blob/master/.travis/push.sh - -# This action can only be done with the actual owner of the repository, -# unless you can extend the collaborator's permissions but as far as I know, you can't. - -# Install required system packages. -apk add curl jq - -# Get a token from hub.docker.com with the owner credentials. -token=$(curl -s \ - -X POST \ - -H "Content-Type: application/json" \ - -d '{"username": "'"$CI_REGISTRY_OWNER_USERNAME"'", "password": "'"$CI_REGISTRY_OWNER_PASSWORD"'"}' \ - https://hub.docker.com/v2/users/login/ | jq -r .token) - -# Generate a JSON with the README.md as the full_description. -json=$(jq -n \ - --arg readme "$( Date: Sat, 4 Jan 2020 10:04:52 +0100 Subject: [PATCH 07/42] Add new CI scripts that check, build, test and publish the images, move the .utilities --- .utilities/build.sh | 32 +++++++++++++ .utilities/check.sh | 47 +++++++++++++++++++ .utilities/publish.sh | 34 ++++++++++++++ .utilities/test.sh | 26 ++++++++++ .../update-docker-hub-full-description.sh | 46 ++++++++++++++++++ .utilities/utilities.sh | 21 +++++++++ 6 files changed, 206 insertions(+) create mode 100644 .utilities/build.sh create mode 100644 .utilities/check.sh create mode 100644 .utilities/publish.sh create mode 100644 .utilities/test.sh create mode 100644 .utilities/update-docker-hub-full-description.sh create mode 100644 .utilities/utilities.sh diff --git a/.utilities/build.sh b/.utilities/build.sh new file mode 100644 index 0000000..ef75070 --- /dev/null +++ b/.utilities/build.sh @@ -0,0 +1,32 @@ +#!/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 . + +# Hard reset to the latest tag. +latest_version=$(git describe --abbrev=0) +git reset --hard $latest_version + +cp -R tests seafile-client/ +cd seafile-client/ + +docker build \ + --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + --build-arg VCS_REF=$(git rev-parse --short HEAD) \ + --build-arg VERSION=$latest_version \ + --tag $CI_PROJECT_NAME:build . + +docker save --output ../$CI_PROJECT_NAME.tar $CI_PROJECT_NAME:build diff --git a/.utilities/check.sh b/.utilities/check.sh new file mode 100644 index 0000000..9160cb0 --- /dev/null +++ b/.utilities/check.sh @@ -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 . + +# 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 diff --git a/.utilities/publish.sh b/.utilities/publish.sh new file mode 100644 index 0000000..8c21ad0 --- /dev/null +++ b/.utilities/publish.sh @@ -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 . + +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 + echo "docker tag $CI_PROJECT_NAME:$tag $CI_REGISTRY_IMAGE:build" + echo "docker push $CI_REGISTRY_IMAGE:$tag" +done diff --git a/.utilities/test.sh b/.utilities/test.sh new file mode 100644 index 0000000..b4b1014 --- /dev/null +++ b/.utilities/test.sh @@ -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 . + +SCRIPT_DIRECTORY=$(dirname ${BASH_SOURCE[0]}) +source $SCRIPT_DIRECTORY/utilities.sh +load_images_artifacts + +docker run \ + --interactive \ + --attach stderr \ + $CI_PROJECT_NAME:build /test/test_binaries.sh diff --git a/.utilities/update-docker-hub-full-description.sh b/.utilities/update-docker-hub-full-description.sh new file mode 100644 index 0000000..ac772b2 --- /dev/null +++ b/.utilities/update-docker-hub-full-description.sh @@ -0,0 +1,46 @@ +#!/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 . + +# Based upon https://gist.github.com/jlhawn/8f218e7c0b14c941c41f +# and https://github.com/moikot/golang-dep/blob/master/.travis/push.sh + +# This action can only be done with the actual owner of the repository, +# unless you can extend the collaborator's permissions but as far as I know, you can't. + +# Install required system packages. +apk add curl jq + +# Get a token from hub.docker.com with the owner credentials. +token=$(curl -s \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{"username": "'"$CI_REGISTRY_OWNER_USERNAME"'", "password": "'"$CI_REGISTRY_OWNER_PASSWORD"'"}' \ + https://hub.docker.com/v2/users/login/ | jq -r .token) + +# Generate a JSON with the README.md as the full_description. +json=$(jq -n \ + --arg readme "$(. + +load_images_artifacts() { + docker load --input $CI_PROJECT_NAME.tar +} From bf2d04f03688a72581140799d26acf341a16192a Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Sat, 4 Jan 2020 10:05:14 +0100 Subject: [PATCH 08/42] Implement the new CI scripts --- .gitlab-ci.yml | 56 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d9f9960..69956d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,40 +1,48 @@ image: docker:latest services: -- docker:dind + - docker:dind stages: -- build_publish + - build + - test + - publish before_script: -- apk add bash + - apk add bash -cron_or_supervisord: - stage: build_publish - script: - - /bin/bash utils/publish/feature--cron-or-supervisord.sh +build: + stage: build + script: /bin/bash .utilities/build.sh only: - - feature--cron-or-supervisord + - tags + - schedules + artifacts: + path: + - $CI_PROJECT_NAME.tar -staging: - stage: build_publish - script: - - /bin/bash utils/publish/staging.sh +test: + stage: test + script: /bin/bash .utilities/test.sh only: - - staging + - tags + - schedules + artifacts: + path: + - $CI_PROJECT_NAME.tar -production: - stage: build_publish - script: - - /bin/bash utils/publish/production.sh +publish: + stage: publish + script: /bin/bash .utilities/publish.sh only: - - tags - except: - - branches + - tags + - schedules + artifacts: + path: + - $CI_PROJECT_NAME.tar update_docker_hub_full_description: - stage: build_publish - script: - - /bin/bash utils/publish/update-docker-hub-full-description.sh + stage: publish + script: /bin/bash .utilities/update-docker-hub-full-description.sh only: - - master \ No newline at end of file + - master From 1741ddb98d999842bdd94c9294b3b506477b6630 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Sat, 4 Jan 2020 10:05:34 +0100 Subject: [PATCH 09/42] Add basic test scripts --- tests/test_binaries.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/test_binaries.sh diff --git a/tests/test_binaries.sh b/tests/test_binaries.sh new file mode 100644 index 0000000..92fb6df --- /dev/null +++ b/tests/test_binaries.sh @@ -0,0 +1,31 @@ +#!/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 . + +failures=() +binaries=(seaf-cli cron oathtool) + +for binary in "${binaries[@]}"; do + if ! [ -x "$(command -v $binary)" ]; then + echo "$binary was not found" + failures+=($binary) + fi +done + +if [ ${#failures[@]} -ne 0 ]; then + exit 1 +fi From d16a21758fe18a99f8070191243216ba0908ae1c Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Sat, 4 Jan 2020 10:07:24 +0100 Subject: [PATCH 10/42] Move Dockerfile and assets, add labels for MicroBadger --- assets/cron/Dockerfile | 67 ---------------- seafile-client/Dockerfile | 77 +++++++++++++++++++ .../docker-entrypoint.sh | 25 ++++-- seafile-client/import-seafile-apt-key.sh | 27 +++++++ .../seafile-entrypoint.sh | 13 +++- .../seafile-healthcheck.sh | 2 +- 6 files changed, 132 insertions(+), 79 deletions(-) delete mode 100644 assets/cron/Dockerfile create mode 100644 seafile-client/Dockerfile rename {assets/cron => seafile-client}/docker-entrypoint.sh (76%) create mode 100644 seafile-client/import-seafile-apt-key.sh rename {assets/cron => seafile-client}/seafile-entrypoint.sh (75%) rename {assets/cron => seafile-client}/seafile-healthcheck.sh (97%) diff --git a/assets/cron/Dockerfile b/assets/cron/Dockerfile deleted file mode 100644 index a6eb293..0000000 --- a/assets/cron/Dockerfile +++ /dev/null @@ -1,67 +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 . - -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 -ENV SEAF_SKIP_SSL_CERT=1 - -# 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"] diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile new file mode 100644 index 0000000..ca49d49 --- /dev/null +++ b/seafile-client/Dockerfile @@ -0,0 +1,77 @@ +# 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 . + +FROM debian:buster-slim + +# For MicroBadger. +ARG BUILD_DATE +ARG VCS_REF +ARG VERSION +LABEL 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" + +# Prevent the packages installation to halt. +ENV DEBIAN_FRONTEND noninteractive +# Create the Seafile client's user. +ENV UNAME=seafuser +ENV UID=1000 +ENV GID=1000 +# Seafile optional configuration. +ENV SEAF_SKIP_SSL_CERT=1 + +# Safely import Seafile APT key, then install both seafile-cli and supervisord. +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 \ + cron && \ + 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 /volume/ && \ + echo "seafuser" > /etc/cron.allow && \ + echo "*/20 * * * * /bin/bash /home/seafuser/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 entrypoints, healthchecks and tests. +COPY docker-entrypoint.sh /entrypoint.sh +COPY seafile-healthcheck.sh /home/seafuser/healthcheck.sh +COPY seafile-entrypoint.sh /home/seafuser/entrypoint.sh +COPY tests /tests + +# Set bash as the entrypoint and run the entrypoint script from that. +ENTRYPOINT ["/bin/bash"] +CMD ["/entrypoint.sh"] \ No newline at end of file diff --git a/assets/cron/docker-entrypoint.sh b/seafile-client/docker-entrypoint.sh similarity index 76% rename from assets/cron/docker-entrypoint.sh rename to seafile-client/docker-entrypoint.sh index 7849471..17f0792 100644 --- a/assets/cron/docker-entrypoint.sh +++ b/seafile-client/docker-entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # 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 # it under the terms of the GNU General Public License as published by @@ -33,18 +33,27 @@ if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID is not defined. Stopping container..." exit 1 fi -if [ -n "$SEAF_UPLOAD_LIMIT" ] -&& [[ $SEAF_UPLOAD_LIMIT =~ ^[0-9]+$ ]] -&& [ "$SEAF_UPLOAD_LIMIT" -gt 0 ]; then +if [[ -n "$SEAF_UPLOAD_LIMIT" +&& $SEAF_UPLOAD_LIMIT =~ ^[0-9]+$ +&& "$SEAF_UPLOAD_LIMIT" -gt 0 ]]; then echo "The \$SEAF_UPLOAD_LIMIT is not an integer greater than 0. Stopping container..." exit 1 fi -if [ -n "$SEAF_DOWNLOAD_LIMIT" ] -&& [[ $SEAF_DOWNLOAD_LIMIT =~ ^[0-9]+$ ]] -&& [ "$SEAF_DOWNLOAD_LIMIT" -gt 0 ]; then +if [[ -n "$SEAF_DOWNLOAD_LIMIT" +&& $SEAF_DOWNLOAD_LIMIT =~ ^[0-9]+$ +&& "$SEAF_DOWNLOAD_LIMIT" -gt 0 ]]; then echo "The \$SEAF_DOWNLOAD_LIMIT is not an integer greater than 0. Stopping container..." exit 1 fi +if [ -n "$SEAF_2FA_SECRET" ]; then + curl -X POST http://2fa:1880/auth \ + -H "Content-Type: application/json" \ + -d '{"secret":"YWAMNW7YTTB2QDU6ENTJ4LIPUYFUG4SW","key":"docker-seaf-cli","desc":"/"}' + if [ $? -ne 0 ]; then + echo "Could create an 2FA token provider at $SEAF_2FA_PROVIDER. curl error $?" + exit 1 + fi +fi # Update the user ID, if the $UID changed. if [ "$UID" != "1000" ]; then @@ -76,6 +85,8 @@ su - $UNAME << EO export SEAF_SKIP_SSL_CERT=$SEAF_SKIP_SSL_CERT test -n "$SEAF_UPLOAD_LIMIT" && export SEAF_UPLOAD_LIMIT=$SEAF_UPLOAD_LIMIT test -n "$SEAF_DOWNLOAD_LIMIT" && export SEAF_DOWNLOAD_LIMIT=$SEAF_DOWNLOAD_LIMIT + test -n "$SEAF_2FA_SECRET" && export SEAF_2FA_SECRET=$SEAF_2FA_SECRET + test -n "$SEAF_LIBRARY_PASSWORD" && export SEAF_LIBRARY_PASSWORD=$SEAF_LIBRARY_PASSWORD export UNAME=$UNAME /bin/bash /home/seafuser/entrypoint.sh EO diff --git a/seafile-client/import-seafile-apt-key.sh b/seafile-client/import-seafile-apt-key.sh new file mode 100644 index 0000000..3a4db2c --- /dev/null +++ b/seafile-client/import-seafile-apt-key.sh @@ -0,0 +1,27 @@ +#!/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 . + +not_imported=true +while $not_imported; do + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8756C4F765C9AC3CB6B85D62379CE192D401AB61 + if [ $? -eq 0 ]; then + not_imported=false + else + sleep 5 + fi +done \ No newline at end of file diff --git a/assets/cron/seafile-entrypoint.sh b/seafile-client/seafile-entrypoint.sh similarity index 75% rename from assets/cron/seafile-entrypoint.sh rename to seafile-client/seafile-entrypoint.sh index dbf22e3..f98208b 100644 --- a/assets/cron/seafile-entrypoint.sh +++ b/seafile-client/seafile-entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # 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 # it under the terms of the GNU General Public License as published by @@ -35,8 +35,13 @@ while [ ! -S $seafile_sock ]; do sleep 1; done test "$SEAF_SKIP_SSL_CERT" = true && seaf-cli config -k disable_verify_certificate -v true # Set the upload/download limits -test -n "$SEAF_UPLOAD_LIMIT" && seaf-cli config -k upload_limit -v $SEAF_UPLOAD_LIMIT +test -n "$SEAF_PLOAD_LIMIT" && seaf-cli config -k upload_limit -v $SEAF_UPLOAD_LIMIT test -n "$SEAF_DOWNLOAD_LIMIT" && seaf-cli config -k download_limit -v $SEAF_DOWNLOAD_LIMIT -# Start the synchronisation. -/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume \ No newline at end of file +# Build the seaf-cli sync command. +cmd="seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID" +test $SEAF_2FA_SECRET && cmd+=" -a $(oathlib --base32 --totp $SEAF_2FA_SECRET)" +test $SEAF_LIBRARY_PASSWORD && cmd+=" -e $SEAF_LIBRARY_PASSWORD" + +# Run it. +if ! eval $cmd; then echo "Failed to sync"; exit 1; fi \ No newline at end of file diff --git a/assets/cron/seafile-healthcheck.sh b/seafile-client/seafile-healthcheck.sh similarity index 97% rename from assets/cron/seafile-healthcheck.sh rename to seafile-client/seafile-healthcheck.sh index 663e03b..1bd54e3 100755 --- a/assets/cron/seafile-healthcheck.sh +++ b/seafile-client/seafile-healthcheck.sh @@ -1,7 +1,7 @@ #!/bin/bash # 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 # it under the terms of the GNU General Public License as published by From a3d1580c6a19797d6ef064bdffd301eefe74aa10 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Sat, 4 Jan 2020 10:14:06 +0100 Subject: [PATCH 11/42] Push years --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index 648524f..23dc218 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE 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 of this license document, but changing it is not allowed. From 39007bf56ef6fa0537d4c217972732bb24e3403a Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 16:11:48 +0100 Subject: [PATCH 12/42] Remove obsolete 2fa setup --- seafile-client/docker-entrypoint.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/seafile-client/docker-entrypoint.sh b/seafile-client/docker-entrypoint.sh index 17f0792..c6de257 100644 --- a/seafile-client/docker-entrypoint.sh +++ b/seafile-client/docker-entrypoint.sh @@ -45,15 +45,6 @@ if [[ -n "$SEAF_DOWNLOAD_LIMIT" echo "The \$SEAF_DOWNLOAD_LIMIT is not an integer greater than 0. Stopping container..." exit 1 fi -if [ -n "$SEAF_2FA_SECRET" ]; then - curl -X POST http://2fa:1880/auth \ - -H "Content-Type: application/json" \ - -d '{"secret":"YWAMNW7YTTB2QDU6ENTJ4LIPUYFUG4SW","key":"docker-seaf-cli","desc":"/"}' - if [ $? -ne 0 ]; then - echo "Could create an 2FA token provider at $SEAF_2FA_PROVIDER. curl error $?" - exit 1 - fi -fi # Update the user ID, if the $UID changed. if [ "$UID" != "1000" ]; then From db9546f71b9ee9b9f55c24be6e0eb508a1a0f5a8 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 16:12:23 +0100 Subject: [PATCH 13/42] Fix healthcheck path --- seafile-client/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seafile-client/docker-entrypoint.sh b/seafile-client/docker-entrypoint.sh index c6de257..cbd7735 100644 --- a/seafile-client/docker-entrypoint.sh +++ b/seafile-client/docker-entrypoint.sh @@ -63,7 +63,7 @@ if [ "$GID" != "1000" ]; then fi # 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 -R /volume From 4b18dc7d6ab5c5c15272bac57b8c546f17b67629 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 16:13:35 +0100 Subject: [PATCH 14/42] Remove cron in favor of tailing the log as a keep-alive method --- seafile-client/docker-entrypoint.sh | 2 -- seafile-client/seafile-entrypoint.sh | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/seafile-client/docker-entrypoint.sh b/seafile-client/docker-entrypoint.sh index cbd7735..95370fc 100644 --- a/seafile-client/docker-entrypoint.sh +++ b/seafile-client/docker-entrypoint.sh @@ -81,5 +81,3 @@ su - $UNAME << EO export UNAME=$UNAME /bin/bash /home/seafuser/entrypoint.sh EO - -cron -f \ No newline at end of file diff --git a/seafile-client/seafile-entrypoint.sh b/seafile-client/seafile-entrypoint.sh index f98208b..a80d19b 100644 --- a/seafile-client/seafile-entrypoint.sh +++ b/seafile-client/seafile-entrypoint.sh @@ -44,4 +44,7 @@ test $SEAF_2FA_SECRET && cmd+=" -a $(oathlib --base32 --totp $SEAF_2FA_SECRET)" test $SEAF_LIBRARY_PASSWORD && cmd+=" -e $SEAF_LIBRARY_PASSWORD" # Run it. -if ! eval $cmd; then echo "Failed to sync"; exit 1; fi \ No newline at end of file +if ! eval $cmd; then echo "Failed to sync"; exit 1; fi + +# Continously print the log. +tail -f ~/.ccnet/logs/seafile.log From c882874383a7cf29f138d5bc5c210a6266807536 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 18:22:05 +0100 Subject: [PATCH 15/42] Add the label maintainer --- seafile-client/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index ca49d49..7585c9a 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -16,11 +16,11 @@ FROM debian:buster-slim -# For MicroBadger. ARG BUILD_DATE ARG VCS_REF ARG VERSION -LABEL org.label-schema.build-date=$BUILD_DATE \ +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 \ From 8b00ea6bcb04ba846e043b07956404b3f7e8ea18 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 18:22:49 +0100 Subject: [PATCH 16/42] Do not install cron --- seafile-client/Dockerfile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index 7585c9a..de1e640 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -50,8 +50,7 @@ RUN apt-get update && apt-get install -y gnupg && \ --no-install-recommends \ --yes \ seafile-cli \ - oathtool \ - cron && \ + oathtool && \ apt-get clean && apt-get autoclean && \ rm -rf \ /var/log/fsck/*.log \ @@ -60,9 +59,6 @@ RUN apt-get update && apt-get install -y gnupg && \ /var/lib/apt/lists/* \ /import-seafile-apt-key.sh && \ mkdir /volume/ && \ - echo "seafuser" > /etc/cron.allow && \ - echo "*/20 * * * * /bin/bash /home/seafuser/healthcheck.sh" \ - > /var/spool/cron/crontabs/seafuser && \ groupadd -g $GID -o $UNAME && \ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME From eb5c9a1650a339c7b7a26d930e2eb98516a08a7e Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 18:25:53 +0100 Subject: [PATCH 17/42] Create the .seafile directory at moment of build --- seafile-client/Dockerfile | 4 +++- seafile-client/seafile-entrypoint.sh | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index de1e640..423befb 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -60,7 +60,9 @@ RUN apt-get update && apt-get install -y gnupg && \ /import-seafile-apt-key.sh && \ mkdir /volume/ && \ groupadd -g $GID -o $UNAME && \ - useradd -m -u $UID -g $GID -o -s /bin/bash $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 entrypoints, healthchecks and tests. COPY docker-entrypoint.sh /entrypoint.sh diff --git a/seafile-client/seafile-entrypoint.sh b/seafile-client/seafile-entrypoint.sh index a80d19b..4c6c796 100644 --- a/seafile-client/seafile-entrypoint.sh +++ b/seafile-client/seafile-entrypoint.sh @@ -20,9 +20,6 @@ seafile_ini=~/.ccnet/seafile.ini seafile_sock=~/.seafile/seafile-data/seafile.sock -# Prepare the directories. -mkdir ~/.seafile - # Safely initialise the Seafile client. /usr/bin/seaf-cli init -d ~/.seafile while [ ! -f $seafile_ini ]; do sleep 1; done From 7543a06f5100d6b6cf735c9e66fe9a43b3665ea7 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 18:27:42 +0100 Subject: [PATCH 18/42] Implement a basic healthcheck --- seafile-client/Dockerfile | 4 +++- seafile-client/docker-healthcheck.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 seafile-client/docker-healthcheck.sh diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index 423befb..2087984 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -66,10 +66,12 @@ RUN apt-get update && apt-get install -y gnupg && \ # Copy over the entrypoints, healthchecks and tests. COPY docker-entrypoint.sh /entrypoint.sh +COPY docker-healthcheck.sh /healthcheck.sh COPY seafile-healthcheck.sh /home/seafuser/healthcheck.sh COPY seafile-entrypoint.sh /home/seafuser/entrypoint.sh COPY tests /tests # Set bash as the entrypoint and run the entrypoint script from that. ENTRYPOINT ["/bin/bash"] -CMD ["/entrypoint.sh"] \ No newline at end of file +CMD ["/entrypoint.sh"] +HEALTHCHECK --interval=5m --start-period=20s --retries=1 CMD ["su", "-", "${UNAME}", "-c", "/healthcheck.sh"] \ No newline at end of file diff --git a/seafile-client/docker-healthcheck.sh b/seafile-client/docker-healthcheck.sh new file mode 100755 index 0000000..298f5e9 --- /dev/null +++ b/seafile-client/docker-healthcheck.sh @@ -0,0 +1,28 @@ +#!/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 . + +# Grab the status of the active repos then return as healthy/unhealthy +# depending the healthy statuses. + +healthy_statuses=("downloading" "waiting for sync", "uploading", "downloading files", "downloading file list") +while IFS=$'\t' read -r name status; do + for healthy_status in "${healthy_statuses[@]}"; do + if [[ "$status" == "$healthy" ]]; then exit 0; fi + done + exit 1 +done < <(seaf-cli status | grep -v "^#") From 179c70a4fa146457cb435b64ebee64d72dc480a5 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 18:28:33 +0100 Subject: [PATCH 19/42] Explicitly close entrypoint options --- seafile-client/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index 2087984..a91e46f 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -71,7 +71,6 @@ COPY seafile-healthcheck.sh /home/seafuser/healthcheck.sh COPY seafile-entrypoint.sh /home/seafuser/entrypoint.sh COPY tests /tests -# Set bash as the entrypoint and run the entrypoint script from that. -ENTRYPOINT ["/bin/bash"] +ENTRYPOINT ["/bin/bash", "--"] CMD ["/entrypoint.sh"] HEALTHCHECK --interval=5m --start-period=20s --retries=1 CMD ["su", "-", "${UNAME}", "-c", "/healthcheck.sh"] \ No newline at end of file From 9bae0fafc9f7f1b255ebf9f89a07742e53377e13 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 18:34:24 +0100 Subject: [PATCH 20/42] Improve minor comments and instructions --- seafile-client/Dockerfile | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index a91e46f..168be51 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -30,16 +30,9 @@ LABEL maintainer="flow.gunso@gmail.com" \ org.label-schema.version=$VERSION \ org.label-schema.schema-version="1.0" -# Prevent the packages installation to halt. -ENV DEBIAN_FRONTEND noninteractive -# Create the Seafile client's user. -ENV UNAME=seafuser -ENV UID=1000 -ENV GID=1000 -# Seafile optional configuration. -ENV SEAF_SKIP_SSL_CERT=1 - -# Safely import Seafile APT key, then install both seafile-cli and supervisord. +# 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/ && \ @@ -64,11 +57,11 @@ RUN apt-get update && apt-get install -y gnupg && \ mkdir /home/$UNAME/.seafile && \ chown $UNAME:$GID /home/$UNAME/.seafile -# Copy over the entrypoints, healthchecks and tests. +# Copy over the assets. COPY docker-entrypoint.sh /entrypoint.sh COPY docker-healthcheck.sh /healthcheck.sh -COPY seafile-healthcheck.sh /home/seafuser/healthcheck.sh COPY seafile-entrypoint.sh /home/seafuser/entrypoint.sh +COPY seafile-healthcheck.sh /home/seafuser/healthcheck.sh COPY tests /tests ENTRYPOINT ["/bin/bash", "--"] From 87c40f3f950efb3f34d1370d06fd171d0be053fb Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 18:35:32 +0100 Subject: [PATCH 21/42] Switch to double bracket tests, reduce redundancy --- seafile-client/docker-entrypoint.sh | 59 ++++++++++------------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/seafile-client/docker-entrypoint.sh b/seafile-client/docker-entrypoint.sh index 95370fc..3494004 100644 --- a/seafile-client/docker-entrypoint.sh +++ b/seafile-client/docker-entrypoint.sh @@ -16,41 +16,25 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +function fail_with_message { + echo "$1" + echo "Exiting container." + exit 1 +} + # Check mandatory Seafile configuration have been properly set. -if [ -z $SEAF_SERVER_URL ]; then - echo "The \$SEAF_SERVER_URL is not defined. Stopping container..." - exit 1 -fi -if [ -z $SEAF_USERNAME ]; then - echo "The \$SEAF_USERNAME is not defined. Stopping container..." - exit 1 -fi -if [ -z $SEAF_PASSWORD ]; then - echo "The \$SEAF_PASSWORD is not defined. Stopping container..." - exit 1 -fi -if [ -z $SEAF_LIBRARY_UUID ]; then - echo "The \$SEAF_LIBRARY_UUID is not defined. Stopping container..." - exit 1 -fi -if [[ -n "$SEAF_UPLOAD_LIMIT" -&& $SEAF_UPLOAD_LIMIT =~ ^[0-9]+$ -&& "$SEAF_UPLOAD_LIMIT" -gt 0 ]]; then - echo "The \$SEAF_UPLOAD_LIMIT is not an integer greater than 0. Stopping container..." - exit 1 -fi -if [[ -n "$SEAF_DOWNLOAD_LIMIT" -&& $SEAF_DOWNLOAD_LIMIT =~ ^[0-9]+$ -&& "$SEAF_DOWNLOAD_LIMIT" -gt 0 ]]; then - echo "The \$SEAF_DOWNLOAD_LIMIT is not an integer greater than 0. Stopping container..." - exit 1 -fi +[[ -z "$SEAF_SERVER_URL" ]] && fail_with_message "The \$SEAF_SERVER_URL is not defined." +[[ -z "$SEAF_USERNAME" ]] && fail_with_message "The \$SEAF_USERNAME is not defined." +[[ -z "$SEAF_PASSWORD" ]] && fail_with_message "The \$SEAF_PASSWORD is not defined." +[[ -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. -if [ "$UID" != "1000" ]; then - usermod -u $UID $UNAME - # What if the $UID already exists ? -fi +# TODO: What if the $UID already exists ? +[[ "$UID" != "1000" ]] && usermod -u $UID $UNAME # Change the group, if the $GID changed. if [ "$GID" != "1000" ]; then @@ -73,11 +57,10 @@ su - $UNAME << EO export SEAF_USERNAME=$SEAF_USERNAME export SEAF_PASSWORD=$SEAF_PASSWORD export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID - export SEAF_SKIP_SSL_CERT=$SEAF_SKIP_SSL_CERT - test -n "$SEAF_UPLOAD_LIMIT" && export SEAF_UPLOAD_LIMIT=$SEAF_UPLOAD_LIMIT - test -n "$SEAF_DOWNLOAD_LIMIT" && export SEAF_DOWNLOAD_LIMIT=$SEAF_DOWNLOAD_LIMIT - test -n "$SEAF_2FA_SECRET" && export SEAF_2FA_SECRET=$SEAF_2FA_SECRET - test -n "$SEAF_LIBRARY_PASSWORD" && export SEAF_LIBRARY_PASSWORD=$SEAF_LIBRARY_PASSWORD - 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 EO From fc271c87225a9b77eea20b9ce25a29fec2a279a4 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 18:37:41 +0100 Subject: [PATCH 22/42] Remove the cron binary from tests --- tests/test_binaries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_binaries.sh b/tests/test_binaries.sh index 92fb6df..0c2a0cb 100644 --- a/tests/test_binaries.sh +++ b/tests/test_binaries.sh @@ -17,7 +17,7 @@ # along with this program. If not, see . failures=() -binaries=(seaf-cli cron oathtool) +binaries=(seaf-cli oathtool) for binary in "${binaries[@]}"; do if ! [ -x "$(command -v $binary)" ]; then From 59cf0d11acbaed4ee349b24ab1ee1967001a663d Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 18:38:20 +0100 Subject: [PATCH 23/42] Switch to double bracket tests, improve readability --- seafile-client/seafile-entrypoint.sh | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/seafile-client/seafile-entrypoint.sh b/seafile-client/seafile-entrypoint.sh index 4c6c796..e46f152 100644 --- a/seafile-client/seafile-entrypoint.sh +++ b/seafile-client/seafile-entrypoint.sh @@ -16,32 +16,30 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Define variable shortcuts for readability purposes. -seafile_ini=~/.ccnet/seafile.ini -seafile_sock=~/.seafile/seafile-data/seafile.sock - # Safely initialise the Seafile client. +seafile_ini=~/.ccnet/seafile.ini /usr/bin/seaf-cli init -d ~/.seafile while [ ! -f $seafile_ini ]; do sleep 1; done # Safely start the Seafile daemon. +seafile_sock=~/.seafile/seafile-data/seafile.sock /usr/bin/seaf-cli start while [ ! -S $seafile_sock ]; do sleep 1; done -# Set the disable_verify_certificate key to true only if the environment variable is true. -test "$SEAF_SKIP_SSL_CERT" = true && seaf-cli config -k disable_verify_certificate -v true +# Set the disable_verify_certificate key to true only if the environment variable exists. +[[ "$SEAF_SKIP_SSL_CERT" ]] && seaf-cli config -k disable_verify_certificate -v true # Set the upload/download limits -test -n "$SEAF_PLOAD_LIMIT" && seaf-cli config -k upload_limit -v $SEAF_UPLOAD_LIMIT -test -n "$SEAF_DOWNLOAD_LIMIT" && seaf-cli config -k download_limit -v $SEAF_DOWNLOAD_LIMIT +[[ "$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" -test $SEAF_2FA_SECRET && cmd+=" -a $(oathlib --base32 --totp $SEAF_2FA_SECRET)" -test $SEAF_LIBRARY_PASSWORD && cmd+=" -e $SEAF_LIBRARY_PASSWORD" +cmd="seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume" +[[ "$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 sync"; exit 1; fi +if ! eval $cmd; then echo "Failed to synchronize."; exit 1; fi # Continously print the log. tail -f ~/.ccnet/logs/seafile.log From 00e72634dafce3478e15579bb04154055b82220c Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 20:40:06 +0100 Subject: [PATCH 24/42] Add new environment variables, format to yaml --- docker-compose.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1d2b8df..4d7c73a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,12 +7,15 @@ services: 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. + 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: your_shared_volume: \ No newline at end of file From dcceb61730b3a657b61b09507d438a9e9725ce4a Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 22:51:50 +0100 Subject: [PATCH 25/42] Change the synchronized path to /library for consistency --- docker-compose.yml | 2 +- seafile-client/Dockerfile | 2 +- seafile-client/seafile-entrypoint.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4d7c73a..8e8344d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: image: flowgunso/seafile-client:latest restart: on-failure volumes: - - your_shared_volume:/volume + - your_shared_volume:/library environment: SEAF_SERVER_URL: "" # The URL to your Seafile server. SEAF_USERNAME: "" # Your Seafile username. diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index 168be51..1a696b7 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -51,7 +51,7 @@ RUN apt-get update && apt-get install -y gnupg && \ /var/cache/debconf/*.dat-old \ /var/lib/apt/lists/* \ /import-seafile-apt-key.sh && \ - mkdir /volume/ && \ + mkdir /library/ && \ groupadd -g $GID -o $UNAME && \ useradd -m -u $UID -g $GID -o -s /bin/bash $UNAME && \ mkdir /home/$UNAME/.seafile && \ diff --git a/seafile-client/seafile-entrypoint.sh b/seafile-client/seafile-entrypoint.sh index e46f152..e9a8b3d 100644 --- a/seafile-client/seafile-entrypoint.sh +++ b/seafile-client/seafile-entrypoint.sh @@ -34,7 +34,7 @@ while [ ! -S $seafile_sock ]; do sleep 1; done [[ "$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 /volume" +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" From 642e98cc127f153b3ea55cad3a4ea6bcf364ca2a Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 22:52:47 +0100 Subject: [PATCH 26/42] Comment the cron-based healthcheck --- seafile-client/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index 1a696b7..6ae2218 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -61,7 +61,7 @@ RUN apt-get update && apt-get install -y gnupg && \ 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 seafile-healthcheck.sh /home/seafuser/healthcheck.sh COPY tests /tests ENTRYPOINT ["/bin/bash", "--"] From ce0e30b50c3441ff80100d3798f82f8042d802f3 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 22:53:32 +0100 Subject: [PATCH 27/42] Revert to the default healthcheck interval --- seafile-client/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seafile-client/Dockerfile b/seafile-client/Dockerfile index 6ae2218..c5c5970 100644 --- a/seafile-client/Dockerfile +++ b/seafile-client/Dockerfile @@ -66,4 +66,4 @@ COPY tests /tests ENTRYPOINT ["/bin/bash", "--"] CMD ["/entrypoint.sh"] -HEALTHCHECK --interval=5m --start-period=20s --retries=1 CMD ["su", "-", "${UNAME}", "-c", "/healthcheck.sh"] \ No newline at end of file +HEALTHCHECK --start-period=20s --retries=1 CMD ["su", "-", "${UNAME}", "-c", "/healthcheck.sh"] \ No newline at end of file From 7a7187deef3e9e1f5dd3a5d5dd2542d61c56074b Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 22:53:51 +0100 Subject: [PATCH 28/42] Remove the restart parameter --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8e8344d..ea279c5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,6 @@ version: "3.4" services: seafile-client: image: flowgunso/seafile-client:latest - restart: on-failure volumes: - your_shared_volume:/library environment: From b0afee7b647af4b64cce5558a08d11126886ddff Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 22:54:52 +0100 Subject: [PATCH 29/42] Move into documentations directory --- docker-compose.yml => documentations/docker-compose.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docker-compose.yml => documentations/docker-compose.yml (100%) diff --git a/docker-compose.yml b/documentations/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to documentations/docker-compose.yml From 6d020b4c2a512a0eac66631af466349b1c5b9428 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 22:59:57 +0100 Subject: [PATCH 30/42] Rename the volume for consistency --- documentations/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentations/docker-compose.yml b/documentations/docker-compose.yml index ea279c5..b362826 100644 --- a/documentations/docker-compose.yml +++ b/documentations/docker-compose.yml @@ -4,7 +4,7 @@ services: seafile-client: image: flowgunso/seafile-client:latest volumes: - - your_shared_volume:/library + - shared_volume:/library environment: SEAF_SERVER_URL: "" # The URL to your Seafile server. SEAF_USERNAME: "" # Your Seafile username. @@ -17,4 +17,4 @@ services: # GID: "" # Default is 1000. volumes: - your_shared_volume: \ No newline at end of file + shared_volume: \ No newline at end of file From 4cbeea381d525c351bd4bb707248ebeaf5a5ef72 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 23:12:21 +0100 Subject: [PATCH 31/42] Revise and reword --- README.md | 143 +++++++++++++++++++++++++++--------------------------- 1 file changed, 71 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 936f259..1c90d04 100644 --- a/README.md +++ b/README.md @@ -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) [![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/) -# Available tags +**Share a Seafile library as a volume to other containers.** -Weekly stable release are built every Monday at 6AM UTC+2. -Permanent stable releases will not be built again. +# Supported tags +[`2`, `2.0`, `2.0.0`, `latest`](seafile-client/Dockerfile) -## Weekly stable releases. -[`1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.1), -[`1.2`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.1), -[`1.2.1`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.1), -[`latest`](https://gitlab.com/flwgns-docker/seafile-client/tags/1.2.1) - -## Developmental releases. -[`staging`](https://gitlab.com/flwgns-docker/seafile-client/tree/staging): -The purpose of this release is to test feature and make them available to anyone. - -# Purpose -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/). +# Informations +* Synchronize a single Seafile library, available at the path `/library/'. +* Password protected librairies are supported. +* Two factor authentication is supported. +* Upload and download speeds are configurable. +* SSL certificates are skippable. + +* Supported tags are rebuilt weekly. + +* Ask questions on [Seafile forum](https://forum.seafile.com/t/docker-client-to-sync-files-with-containers/8573). +* Contribute and report issues on [Gitlab](https://gitlab.com/flwgns-docker/seafile-client/). # 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. -The *supervisord* is running from `~/.supervisord/`, the `supervisord.conf`, `supervisord.log` and `supervisord.pid` can be found there. -*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. -## Examples -You would have to share the path `/volume/` to other containers, with the following approaches: -### Docker CLI +## Optional configurations +__SEAF_2FA_SECRET__ +_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. + +__SEAF_LIBRARY_PASSWORD__ +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 \ - -e SEAF_SERVER_URL= \ # The URL to your Seafile server. - -e SEAF_USERNAME= \ # Your Seafile username. - -e SEAF_PASSWORD= \ # Your Seafile password - -e SEAF_LIBRARY_UUID= \ # The Seafile library UUID you want to sync with. - -e UID= \ # Default is 1000. - -e GID= \ # Default is 1000. - -v your/shared/volume:/volume \ + -e SEAF_SERVER_URL=https://seafile.example/ + -e SEAF_USERNAME=a_seafile_user + -e SEAF_PASSWORD=SoMePaSSWoRD + -e SEAF_LIBRARY_UUID=an-hexadecimal-library-uuid + -v path/to/shared/volume:/library \ flowgunso/seafile-client:latest ``` -### docker-compose +## As a Docker Compose ```yaml -version: "3.4" - services: + seafile-client: image: flowgunso/seafile-client:latest - restart: on-failure volumes: - - your_shared_volume:/volume + - 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. - - UID= # Default is 1000. - - GID= # Default is 1000. + SEAF_SERVER_URL: "https://seafile.example/" + SEAF_USERNAME: "a_seafile_user" + SEAF_PASSWORD: "SoMePaSSWoRD" + SEAF_LIBRARY_UUID: "an-hexadecimal-library-uuid" 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 -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/seafile-client](https://gitlab.com/flwgns-docker/seafile-client/). \ No newline at end of file +volumes: + shared_volume: +``` +Or use the [docker-compose.yml](documentations/docker-compose.yml) template. \ No newline at end of file From c24858ce591033b0fcd19b31ac57d23b3fa9fd1c Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 23:12:35 +0100 Subject: [PATCH 32/42] Log the changes for 2.0 --- CHANGELOG.md | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d4a41e..3e4c7eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: - 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 - -## [1.2.0] - 2019/05/02 +## __[1.2.0](https://gitlab.com/flwgns-docker/seafile-client/-/tags/1.2.0)__ | _2019/05/02_ - 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. -### [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%. -### [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) -## [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 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 -### [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 -### [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) - 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) - 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 production pipelines to pushed and triggered 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. -### [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 - 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 -# [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 From 29c0dac5647c4b40098ce63123409502ea6353a9 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 23:13:00 +0100 Subject: [PATCH 33/42] Enable build and tests for the milestone--2.0 branch --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 69956d1..92b8b00 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,6 +17,7 @@ build: only: - tags - schedules + - milestone--2.0 artifacts: path: - $CI_PROJECT_NAME.tar @@ -27,6 +28,7 @@ test: only: - tags - schedules + - milestone--2.0 artifacts: path: - $CI_PROJECT_NAME.tar From 0e15bc856d59d59980a5d98c1ed42727cfb991de Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 23:16:57 +0100 Subject: [PATCH 34/42] Fix the artifact paths key --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 92b8b00..b58578a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ build: - schedules - milestone--2.0 artifacts: - path: + paths: - $CI_PROJECT_NAME.tar test: @@ -30,7 +30,7 @@ test: - schedules - milestone--2.0 artifacts: - path: + paths: - $CI_PROJECT_NAME.tar publish: @@ -40,7 +40,7 @@ publish: - tags - schedules artifacts: - path: + paths: - $CI_PROJECT_NAME.tar update_docker_hub_full_description: From f2783a04b3f1a4081e10ed449b545e1c2f7580d0 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Mon, 6 Jan 2020 23:29:22 +0100 Subject: [PATCH 35/42] Install git in before_script, run script with -e flag to catch failures --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b58578a..eadb103 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,11 +9,11 @@ stages: - publish before_script: - - apk add bash + - apk add bash git build: stage: build - script: /bin/bash .utilities/build.sh + script: /bin/bash -e .utilities/build.sh only: - tags - schedules @@ -24,7 +24,7 @@ build: test: stage: test - script: /bin/bash .utilities/test.sh + script: /bin/bash -e .utilities/test.sh only: - tags - schedules @@ -35,7 +35,7 @@ test: publish: stage: publish - script: /bin/bash .utilities/publish.sh + script: /bin/bash -e .utilities/publish.sh only: - tags - schedules @@ -45,6 +45,6 @@ publish: update_docker_hub_full_description: stage: publish - script: /bin/bash .utilities/update-docker-hub-full-description.sh + script: /bin/bash -e .utilities/update-docker-hub-full-description.sh only: - master From 84e299e4ddb8ede10f8b46984168acba2b9c4651 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Tue, 7 Jan 2020 10:13:25 +0100 Subject: [PATCH 36/42] Divide jobs and scripts by use case --- .gitlab-ci.yml | 30 +++++++++++++----- .utilities/{build.sh => build.schedules.sh} | 0 .utilities/build.tags.sh | 28 +++++++++++++++++ .utilities/publish.schedules.sh | 34 +++++++++++++++++++++ .utilities/{publish.sh => publish.tags.sh} | 2 +- 5 files changed, 86 insertions(+), 8 deletions(-) rename .utilities/{build.sh => build.schedules.sh} (100%) create mode 100644 .utilities/build.tags.sh create mode 100644 .utilities/publish.schedules.sh rename .utilities/{publish.sh => publish.tags.sh} (94%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eadb103..58e9e9d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,20 +11,28 @@ stages: before_script: - apk add bash git -build: +build.tags: stage: build - script: /bin/bash -e .utilities/build.sh + script: /bin/bash -e utilities/build.tags.sh only: - tags - - schedules - milestone--2.0 artifacts: 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 + script: /bin/bash -e utilities/test.sh only: - tags - schedules @@ -33,11 +41,19 @@ test: paths: - $CI_PROJECT_NAME.tar -publish: +publish.tags: stage: publish - script: /bin/bash -e .utilities/publish.sh + 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: @@ -45,6 +61,6 @@ publish: update_docker_hub_full_description: stage: publish - script: /bin/bash -e .utilities/update-docker-hub-full-description.sh + script: /bin/bash -e utilities/update-docker-hub-full-description.sh only: - master diff --git a/.utilities/build.sh b/.utilities/build.schedules.sh similarity index 100% rename from .utilities/build.sh rename to .utilities/build.schedules.sh diff --git a/.utilities/build.tags.sh b/.utilities/build.tags.sh new file mode 100644 index 0000000..2812b0b --- /dev/null +++ b/.utilities/build.tags.sh @@ -0,0 +1,28 @@ +#!/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 . + +cp -R tests seafile-client/ +cd seafile-client/ + +docker build \ + --build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + --build-arg VCS_REF=$(git rev-parse --short HEAD) \ + --build-arg VERSION=$latest_version \ + --tag $CI_PROJECT_NAME:build . + +docker save --output ../$CI_PROJECT_NAME.tar $CI_PROJECT_NAME:build diff --git a/.utilities/publish.schedules.sh b/.utilities/publish.schedules.sh new file mode 100644 index 0000000..bbdcb02 --- /dev/null +++ b/.utilities/publish.schedules.sh @@ -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 . + +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 + echo "docker tag $CI_PROJECT_NAME:$tag $CI_REGISTRY_IMAGE:build" + echo "docker push $CI_REGISTRY_IMAGE:$tag" +done diff --git a/.utilities/publish.sh b/.utilities/publish.tags.sh similarity index 94% rename from .utilities/publish.sh rename to .utilities/publish.tags.sh index 8c21ad0..e78bdf2 100644 --- a/.utilities/publish.sh +++ b/.utilities/publish.tags.sh @@ -21,7 +21,7 @@ source $SCRIPT_DIRECTORY/utilities.sh load_images_artifacts tags=("latest") -for version_component in $(git describe --abbrev=0 | tr "." "\n"); do +for version_component in "$CI_COMMIT_TAG"; do tag+="$version_component" tags+=("$tag") tag+="." From 34df27de8f7c0c413641850a50fa02caa4b95ae3 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Tue, 7 Jan 2020 10:16:10 +0100 Subject: [PATCH 37/42] Fix the scripts paths --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 58e9e9d..ea3494f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,7 +13,7 @@ before_script: build.tags: stage: build - script: /bin/bash -e utilities/build.tags.sh + script: /bin/bash -e .utilities/build.tags.sh only: - tags - milestone--2.0 @@ -23,7 +23,7 @@ build.tags: build.schedules: stage: build - script: /bin/bash -e utilities/build.schedules.sh + script: /bin/bash -e .utilities/build.schedules.sh only: - schedules artifacts: @@ -32,7 +32,7 @@ build.schedules: test: stage: test - script: /bin/bash -e utilities/test.sh + script: /bin/bash -e .utilities/test.sh only: - tags - schedules @@ -43,7 +43,7 @@ test: publish.tags: stage: publish - script: /bin/bash -e utilities/publish.tags.sh + script: /bin/bash -e .utilities/publish.tags.sh only: - tags artifacts: @@ -52,7 +52,7 @@ publish.tags: publish.schedules: stage: publish - script: /bin/bash -e utilities/publish.schedules.sh + script: /bin/bash -e .utilities/publish.schedules.sh only: - schedules artifacts: @@ -61,6 +61,6 @@ publish.schedules: update_docker_hub_full_description: stage: publish - script: /bin/bash -e utilities/update-docker-hub-full-description.sh + script: /bin/bash -e .utilities/update-docker-hub-full-description.sh only: - master From ff117e8b9528ad7379b6d190a08716a89bc705be Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Tue, 7 Jan 2020 10:34:35 +0100 Subject: [PATCH 38/42] Display successful tests --- tests/test_binaries.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_binaries.sh b/tests/test_binaries.sh index 0c2a0cb..09c79f6 100644 --- a/tests/test_binaries.sh +++ b/tests/test_binaries.sh @@ -23,6 +23,8 @@ 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 From a2ad2990ea5b049687018a35f70fde71d422e8e5 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Tue, 7 Jan 2020 10:34:49 +0100 Subject: [PATCH 39/42] Fix path to tests --- .utilities/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.utilities/test.sh b/.utilities/test.sh index b4b1014..a110ab5 100644 --- a/.utilities/test.sh +++ b/.utilities/test.sh @@ -23,4 +23,4 @@ load_images_artifacts docker run \ --interactive \ --attach stderr \ - $CI_PROJECT_NAME:build /test/test_binaries.sh + $CI_PROJECT_NAME:build /tests/test_binaries.sh From 2344c6027e850797bb2b57e38db7a21a1dbc57c8 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Tue, 7 Jan 2020 12:14:20 +0100 Subject: [PATCH 40/42] Add the milestone--2.0 branch to the CI publish job --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea3494f..37ea3cc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,6 +46,7 @@ publish.tags: script: /bin/bash -e .utilities/publish.tags.sh only: - tags + - milestone--2.0 artifacts: paths: - $CI_PROJECT_NAME.tar From 7712fb806609b682d58f31751c81542dc3e0727e Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Tue, 7 Jan 2020 12:21:28 +0100 Subject: [PATCH 41/42] Add pre-check, remove milestone--2.0 from CI jobs --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 37ea3cc..6b64095 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,13 +10,13 @@ stages: before_script: - apk add bash git + - /bin/bash .utilities/check.sh build.tags: stage: build script: /bin/bash -e .utilities/build.tags.sh only: - tags - - milestone--2.0 artifacts: paths: - $CI_PROJECT_NAME.tar @@ -36,7 +36,6 @@ test: only: - tags - schedules - - milestone--2.0 artifacts: paths: - $CI_PROJECT_NAME.tar @@ -46,7 +45,6 @@ publish.tags: script: /bin/bash -e .utilities/publish.tags.sh only: - tags - - milestone--2.0 artifacts: paths: - $CI_PROJECT_NAME.tar From 474a2f26ad8e979c1c3d6a0ccc30559d3ab72788 Mon Sep 17 00:00:00 2001 From: "flow.gunso" Date: Tue, 7 Jan 2020 20:58:47 +0100 Subject: [PATCH 42/42] Uncomment the Docker tag/push --- .utilities/publish.schedules.sh | 4 ++-- .utilities/publish.tags.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.utilities/publish.schedules.sh b/.utilities/publish.schedules.sh index bbdcb02..af9f7e0 100644 --- a/.utilities/publish.schedules.sh +++ b/.utilities/publish.schedules.sh @@ -29,6 +29,6 @@ done echo $CI_REGISTRY_BOT_PASSWORD | docker login --password-stdin --username $CI_REGISTRY_BOT_USERNAME for tag in "${tags[@]}"; do - echo "docker tag $CI_PROJECT_NAME:$tag $CI_REGISTRY_IMAGE:build" - echo "docker push $CI_REGISTRY_IMAGE:$tag" + docker tag $CI_PROJECT_NAME:$tag $CI_REGISTRY_IMAGE:build + docker push $CI_REGISTRY_IMAGE:$tag done diff --git a/.utilities/publish.tags.sh b/.utilities/publish.tags.sh index e78bdf2..2287429 100644 --- a/.utilities/publish.tags.sh +++ b/.utilities/publish.tags.sh @@ -29,6 +29,6 @@ done echo $CI_REGISTRY_BOT_PASSWORD | docker login --password-stdin --username $CI_REGISTRY_BOT_USERNAME for tag in "${tags[@]}"; do - echo "docker tag $CI_PROJECT_NAME:$tag $CI_REGISTRY_IMAGE:build" - echo "docker push $CI_REGISTRY_IMAGE:$tag" + docker tag $CI_PROJECT_NAME:$tag $CI_REGISTRY_IMAGE:build + docker push $CI_REGISTRY_IMAGE:$tag done