fulltextsearch icon indicating copy to clipboard operation
fulltextsearch copied to clipboard

Find a place for example with fulltextsearch:live in Docker

Open robeatoz opened this issue 3 years ago • 0 comments

I created a setup with Nextcloud in a docker container with fulltextsearch. As already mentioned in #436 and #534 new files and other entities will not be indexed after fulltextsearch:index with cron, even not with manual execution of php cron.php. To achieve this without cron, I used supervisor like described in https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/cron/apache/supervisord.conf to create an all-in-one self containing container which handles cron and fulltextsearch:live.

I believe others would like to use this to get an idea of how to handle fulltextsearch:live in a docker container, but I did not find a suitable place for this.

Here is my setup, improvement suggestions are welcome!

Dockerfile:

FROM nextcloud:23.0.1-apache

# Install tesseract and ocrmypdf for OCR
# Install supervisor to start multiple processes on container startup
RUN apt-get update \
    && apt-get install -y  \
      tesseract-ocr \
      tesseract-ocr-deu \
      tesseract-ocr-eng \
      ocrmypdf \
      supervisor \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

RUN mkdir "/var/log/supervisord"
RUN mkdir "/var/run/supervisord"

COPY supervisord.conf /
COPY start_fulltextsearch_live.sh /

# The install and update script is only triggered when a default command is used (apache-foreground or php-fpm).
# If you use a custom command you have to enable the install / update
# See https://github.com/nextcloud/docker
ENV NEXTCLOUD_UPDATE=1

CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]

start_fulltextsearch_live.sh

#!/bin/sh
# Stop all running indexes
php /var/www/html/occ fulltextsearch:stop
# Start live index
php /var/www/html/occ fulltextsearch:live

# More information: https://github.com/nextcloud/fulltextsearch/wiki/Commands

supervisord.conf

; Inspired by https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/cron/apache/supervisord.conf
[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisord/supervisord.log
pidfile=/var/run/supervisord/supervisord.pid
childlogdir=/var/log/supervisord/
logfile_maxbytes=50MB                           ; maximum size of logfile before rotation
logfile_backups=10                              ; number of backed up logfiles
loglevel=error

[program:apache2]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
user=root
command=apache2-foreground  ; Has to be the same command as CMD in original Dockerfile, see https://github.com/nextcloud/docker/blob/master/23/apache/Dockerfile#L158

[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 /start_fulltextsearch_live.sh

robeatoz avatar Feb 13 '22 20:02 robeatoz