Skip to content

Commit

Permalink
Add supervisor and start cron + fulltextsearch:live from container.
Browse files Browse the repository at this point in the history
  • Loading branch information
llaumgui committed Sep 17, 2023
1 parent de7188e commit 628d923
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 7 deletions.
46 changes: 39 additions & 7 deletions 8.2-nextcloud/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,37 @@ LABEL org.opencontainers.image.version="8.2"
# Fix hadolint #DL4006 (https://github.com/hadolint/hadolint/wiki/DL4006)
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update

Check failure on line 16 in 8.2-nextcloud/Dockerfile

View workflow job for this annotation

GitHub Actions / Linters for Dockerfile

DL3009 info: Delete the apt-get lists after installing something

# ----------------------------------------------------------------- Install cron
RUN apt-get install -y --no-install-recommends \
busybox-static && \
mkdir -p /var/spool/cron/crontabs && \
echo '*/5 * * * * php -f /var/www/cron.php' > /var/spool/cron/crontabs/www-data
COPY --chmod=755 cron.sh /


# ------------------------------------------------------------------ Supervisord
RUN apt-get install -y --no-install-recommends \
# Install supervisor to start multiple processes on container startup \
supervisor
RUN mkdir "/var/run/supervisor"
RUN rm -rf /etc/supervisor/*
COPY supervisor/*.conf /etc/supervisor
COPY supervisor/*.sh /


# ----------------------------------------------------- Install Search and cron utilities
RUN apt-get install -y --no-install-recommends \
# Install tesseract and ocrmypdf for OCR \
tesseract-ocr \
tesseract-ocr-fra \
tesseract-ocr-eng \
ocrmypdf


# ------------------------------------------------------------ Install utilities
RUN apt-get update && \
apt-get install -y --no-install-recommends \
RUN apt-get install -y --no-install-recommends \
# Misc tools \
bzip2 \
curl \
Expand All @@ -27,9 +54,9 @@ RUN apt-get update && \
libmagickcore-6.q16-6-extra \
libpng16-16 \
libzip4 \
procps \
unzip \
wget && \
rm -rf /var/lib/apt/lists/*
wget


# --------------------------------------------------------- Install dependancies
Expand All @@ -54,7 +81,6 @@ RUN fetchDeps=" \
# Build dependencies for Zip \
libzip-dev \
# Misc build dependencies \
busybox-static \
libcurl4-openssl-dev \
libevent-dev \
libmcrypt-dev \
Expand Down Expand Up @@ -103,7 +129,11 @@ RUN fetchDeps=" \
\
# ------------------------------------------------------------------ Big cleanup \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false ${fetchDeps}; \
rm -rf /var/lib/apt/lists/*
apt clean && \
rm -rf /var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/usr/share/doc/*


# -------------------------------------------------- Install php-fpm-healthcheck
Expand All @@ -117,9 +147,11 @@ RUN sed -i 's#^;pm.status_path = .*#pm.status_path = /status#g' /usr/local/etc/p
COPY php.d /usr/local/etc/php/conf.d
COPY etc /usr/local/etc/php


# Healthcheck
HEALTHCHECK --interval=1m --timeout=10s --start-period=1m --retries=3 CMD FCGI_CONNECT=localhost:9000 php-fpm-healthcheck

EXPOSE 9000
WORKDIR /var/www

ENTRYPOINT []
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
4 changes: 4 additions & 0 deletions 8.2-nextcloud/cron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -eu

exec busybox crond -f -l 0 -L /dev/stdout
7 changes: 7 additions & 0 deletions 8.2-nextcloud/supervisor/nc_fulltextsearch_live.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# If fulltextsearch is present: stop all running indexes before start live.
[ -d /var/www/apps/fulltextsearch ] && echo php /var/www/occ fulltextsearch:stop

# If fulltextsearch is present: start live index
[ -d /var/www/apps/fulltextsearch ] && php /var/www/occ fulltextsearch:live
34 changes: 34 additions & 0 deletions 8.2-nextcloud/supervisor/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
; Inspired by https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/cron/apache/supervisord.conf
[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisor/supervisord.pid
childlogdir=/var/log/supervisor/
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error

[program:php-fpm]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
user=root # Run as root because using config to start process like www-data.
command=php-fpm

[program:cron]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
user=root
command=/cron.sh

[program:fulltextsearch_index_live]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
user=www-data
command=/bin/sh /nc_fulltextsearch_live.sh

0 comments on commit 628d923

Please sign in to comment.