From 75c24cf3c9c4f9c4e2bdcb0f4d29c2b4914e9337 Mon Sep 17 00:00:00 2001 From: Quentin Duchemin <quentinduchemin@tuta.io> Date: Sun, 16 Aug 2020 18:23:31 +0200 Subject: [PATCH] [Lufi] Add cron tasks --- pica-lufi/Dockerfile | 30 ++++++++++++++++++++++++++---- pica-lufi/docker-compose.yml | 1 - pica-lufi/entrypoint.sh | 14 ++++++++++++++ pica-lufi/lufi.conf | 2 +- 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 pica-lufi/entrypoint.sh diff --git a/pica-lufi/Dockerfile b/pica-lufi/Dockerfile index c4e51322..5d5e0ffe 100644 --- a/pica-lufi/Dockerfile +++ b/pica-lufi/Dockerfile @@ -1,19 +1,41 @@ FROM debian:buster ARG LUFI_BUILD_VERSION=0.05.2 -ARG APP_HOME=/lufi +ENV APP_HOME=/lufi +# Install dependencies RUN apt-get update \ -&& apt-get -yq install build-essential libssl-dev libio-socket-ssl-perl liblwp-protocol-https-perl libpq-dev wget unzip \ +&& apt-get -yq install build-essential libssl-dev libio-socket-ssl-perl liblwp-protocol-https-perl libpq-dev zlib1g-dev wget unzip \ && apt-get clean && cpan Carton +# Install Supercronic to run cron jobs +# (delete IP, delete old files...) +ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-linux-amd64 \ + SUPERCRONIC=supercronic-linux-amd64 \ + SUPERCRONIC_SHA1SUM=5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85 + +RUN curl -fsSLO "$SUPERCRONIC_URL" \ + && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ + && chmod +x "$SUPERCRONIC" \ + && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ + && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic + +# Get Lufi release RUN wget https://github.com/ldidry/lufi/archive/${LUFI_BUILD_VERSION}.zip && unzip ${LUFI_BUILD_VERSION}.zip \ && rm ${LUFI_BUILD_VERSION}.zip && mv lufi-${LUFI_BUILD_VERSION} lufi WORKDIR ${APP_HOME} +# Install Lufi's dependencies RUN carton install --deployment --without=test --without=sqlite --without=mysql -CMD ["carton", "exec", "hypnotoad", "-f", "/lufi/script/lufi"] - +# Add custom theme COPY picadrop ${APP_HOME}/themes/picadrop + +# Add custom entrypoint + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] + +CMD ["carton", "exec", "hypnotoad", "-f", "/lufi/script/lufi"] diff --git a/pica-lufi/docker-compose.yml b/pica-lufi/docker-compose.yml index a5f7a392..e63904ba 100644 --- a/pica-lufi/docker-compose.yml +++ b/pica-lufi/docker-compose.yml @@ -15,7 +15,6 @@ services: image: registry.picasoft.net/lufi:0.05.2 build: . container_name: lufi - init: true depends_on: - lufidb volumes: diff --git a/pica-lufi/entrypoint.sh b/pica-lufi/entrypoint.sh new file mode 100644 index 00000000..3ff0b542 --- /dev/null +++ b/pica-lufi/entrypoint.sh @@ -0,0 +1,14 @@ +echo "Create crontab for cleaning tasks..." + +# See https://framagit.org/fiat-tux/hat-softwares/lufi/-/wikis/cron-jobs +# Delete the IP addresses of file's senders after a configurable delay +echo "0 0 * * * carton exec $APP_HOME/script/lufi cron cleanbdd --mode production" > /crontab.conf +# Delete files which availability delay is over +echo "0 0 * * * carton exec $APP_HOME/script/lufi cron cleanfiles --mode production" > /crontab.conf + + +echo "Start Lufi..." +exec $@ + +echo "Start supercronic..." +supercronic crontab.conf diff --git a/pica-lufi/lufi.conf b/pica-lufi/lufi.conf index fa4f5054..2ac18b71 100644 --- a/pica-lufi/lufi.conf +++ b/pica-lufi/lufi.conf @@ -319,7 +319,7 @@ # Max size of the files directory, in octets # Used by script/lufi cron watch to trigger an action # optional, no default - max_total_size => 10*1024*1024*1024, + # max_total_size => 10*1024*1024*1024, # Default action when files directory is over max_total_size (used with script/lufi cron watch) # Valid values are 'warn', 'stop-upload' and 'delete' -- GitLab