Move Dockerfile and assets, add labels for MicroBadger

This commit is contained in:
flow.gunso
2020-01-04 10:07:24 +01:00
parent 1741ddb98d
commit d16a21758f
6 changed files with 132 additions and 79 deletions

View File

@@ -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 <https://www.gnu.org/licenses/>.
FROM debian:buster-slim
# Prevent the packages installation to halt.
ENV DEBIAN_FRONTEND noninteractive
# Create the seafile client user.
ENV UNAME=seafuser
ENV UID=1000
ENV GID=1000
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"]

77
seafile-client/Dockerfile Normal file
View File

@@ -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 <https://www.gnu.org/licenses/>.
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"]

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -33,18 +33,27 @@ if [ -z $SEAF_LIBRARY_UUID ]; then
echo "The \$SEAF_LIBRARY_UUID is not defined. Stopping container..." echo "The \$SEAF_LIBRARY_UUID is not defined. Stopping container..."
exit 1 exit 1
fi fi
if [ -n "$SEAF_UPLOAD_LIMIT" ] if [[ -n "$SEAF_UPLOAD_LIMIT"
&& [[ $SEAF_UPLOAD_LIMIT =~ ^[0-9]+$ ]] && $SEAF_UPLOAD_LIMIT =~ ^[0-9]+$
&& [ "$SEAF_UPLOAD_LIMIT" -gt 0 ]; then && "$SEAF_UPLOAD_LIMIT" -gt 0 ]]; then
echo "The \$SEAF_UPLOAD_LIMIT is not an integer greater than 0. Stopping container..." echo "The \$SEAF_UPLOAD_LIMIT is not an integer greater than 0. Stopping container..."
exit 1 exit 1
fi fi
if [ -n "$SEAF_DOWNLOAD_LIMIT" ] if [[ -n "$SEAF_DOWNLOAD_LIMIT"
&& [[ $SEAF_DOWNLOAD_LIMIT =~ ^[0-9]+$ ]] && $SEAF_DOWNLOAD_LIMIT =~ ^[0-9]+$
&& [ "$SEAF_DOWNLOAD_LIMIT" -gt 0 ]; then && "$SEAF_DOWNLOAD_LIMIT" -gt 0 ]]; then
echo "The \$SEAF_DOWNLOAD_LIMIT is not an integer greater than 0. Stopping container..." echo "The \$SEAF_DOWNLOAD_LIMIT is not an integer greater than 0. Stopping container..."
exit 1 exit 1
fi 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. # Update the user ID, if the $UID changed.
if [ "$UID" != "1000" ]; then if [ "$UID" != "1000" ]; then
@@ -76,6 +85,8 @@ su - $UNAME << EO
export SEAF_SKIP_SSL_CERT=$SEAF_SKIP_SSL_CERT export SEAF_SKIP_SSL_CERT=$SEAF_SKIP_SSL_CERT
test -n "$SEAF_UPLOAD_LIMIT" && export SEAF_UPLOAD_LIMIT=$SEAF_UPLOAD_LIMIT 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_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 export UNAME=$UNAME
/bin/bash /home/seafuser/entrypoint.sh /bin/bash /home/seafuser/entrypoint.sh
EO EO

View File

@@ -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 <https://www.gnu.org/licenses/>.
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

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume. # Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com # Copyright (C) 2019-2020, flow.gunso@gmail.com
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -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 test "$SEAF_SKIP_SSL_CERT" = true && seaf-cli config -k disable_verify_certificate -v true
# Set the upload/download limits # 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 test -n "$SEAF_DOWNLOAD_LIMIT" && seaf-cli config -k download_limit -v $SEAF_DOWNLOAD_LIMIT
# Start the synchronisation. # Build the seaf-cli sync command.
/usr/bin/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"
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

View File

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