feat(docker): use supervisord (#3129)

This commit is contained in:
Alexis Saettler
2019-10-25 20:38:06 +02:00
committed by GitHub
parent 689fc0dfcc
commit b8d2ed65ec
9 changed files with 106 additions and 21 deletions
+6 -4
View File
@@ -18,7 +18,7 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
RUN apk update && apk upgrade
RUN apk add --virtual .build-deps \
curl openssl bash
RUN apk add netcat-openbsd \
RUN apk add supervisor netcat-openbsd \
#- base
php7 php7-intl php7-openssl php7-ctype \
php7-zip php7-zlib \
@@ -114,7 +114,7 @@ RUN set -ex && \
cd /etc/periodic/hourly/ && \
{ \
echo '#!/bin/sh'; \
echo '/usr/bin/php /var/www/monica/artisan schedule:run -v'; \
echo '/usr/bin/php /var/www/monica/artisan schedule:run -v > /proc/1/fd/1 2> /proc/1/fd/2'; \
} | tee monica && \
chmod a+x monica
@@ -127,10 +127,12 @@ ENTRYPOINT ["entrypoint.sh"]
# Apache2
RUN apk add apache2 php7-apache2
COPY scripts/docker/apache2-foreground /usr/local/sbin/
COPY scripts/docker/apache2-foreground /usr/local/bin/
COPY scripts/docker/000-default.conf /etc/apache2/conf.d/
RUN echo 'LoadModule rewrite_module modules/mod_rewrite.so' > /etc/apache2/conf.d/rewrite.conf
RUN echo 'ServerName "monica"' > /etc/apache2/conf.d/hostname.conf
EXPOSE 80
CMD ["apache2-foreground"]
COPY scripts/docker/apache/supervisord.conf /etc/supervisord.conf
CMD ["supervisord", "-c /etc/supervisord.conf"]
+30
View File
@@ -0,0 +1,30 @@
[supervisord]
nodaemon=true
user=root
[program:cron]
command=/usr/sbin/crond -f -l 0
autostart=true
autorestart=true
[program:queue]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/monica/artisan queue:work --sleep=10 --timeout=0 --tries=3 --queue=default,migration
numprocs=1
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/proc/1/fd/2
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
startretries=0
[program:httpd]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/bin/apache2-foreground
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/proc/1/fd/2
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
-5
View File
@@ -1,10 +1,5 @@
#!/bin/sh
# Run fpm
if [ -f /etc/apache2/conf-enabled/php7.3-fpm.conf ]; then
service php7.3-fpm start
fi
# Run apache2
mkdir -p /run/apache2
rm -f /run/apache2/httpd.pid
+1 -8
View File
@@ -23,7 +23,7 @@ waitfordb() {
sleep 3
}
if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm7" ]; then
if expr "$1" : "supervisord" 1>/dev/null; then
MONICADIR=/var/www/monica
ARTISAN="php ${MONICADIR}/artisan"
@@ -61,13 +61,6 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm7" ]; then
echo "! Please be careful to backup /var/www/monica/storage/oauth-public.key and /var/www/monica/storage/oauth-private.key files !"
fi
# Run cron
if [ -f "/usr/sbin/crond" ]; then
crond -b -l 0 -L /dev/stdout
elif [ -f "/etc/init.d/cron" ]; then
service cron start
fi
fi
exec $@
+4 -2
View File
@@ -114,7 +114,7 @@ RUN set -ex && \
cd /etc/periodic/hourly/ && \
{ \
echo '#!/bin/sh'; \
echo '/usr/bin/php /var/www/monica/artisan schedule:run -v'; \
echo '/usr/bin/php /var/www/monica/artisan schedule:run -v > /proc/1/fd/1 2> /proc/1/fd/2'; \
} | tee monica && \
chmod a+x monica
@@ -152,4 +152,6 @@ RUN set -ex && \
STOPSIGNAL SIGQUIT
EXPOSE 9000
CMD ["php-fpm7"]
COPY scripts/docker/fpm/supervisord.conf /etc/supervisord.conf
CMD ["supervisord", "-c /etc/supervisord.conf"]
+30
View File
@@ -0,0 +1,30 @@
[supervisord]
nodaemon=true
user=root
[program:cron]
command=/usr/sbin/crond -f -l 0
autostart=true
autorestart=true
[program:queue]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/monica/artisan queue:work --sleep=10 --timeout=0 --tries=3 --queue=default,migration
numprocs=1
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/proc/1/fd/2
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
startretries=0
[program:fpm]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php-fpm7
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/proc/1/fd/2
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
+4 -2
View File
@@ -114,7 +114,7 @@ RUN set -ex && \
cd /etc/cron.hourly && \
{ \
echo '#!/bin/sh'; \
echo '/usr/bin/php /var/www/monica/artisan schedule:run -v'; \
echo '/usr/bin/php /var/www/monica/artisan schedule:run -v > /proc/1/fd/1 2> /proc/1/fd/2'; \
} | tee monica && \
chmod a+x monica
@@ -129,4 +129,6 @@ RUN a2enconf hostname
RUN a2enmod rewrite cache headers
EXPOSE 80
CMD ["apache2-foreground"]
COPY scripts/docker/php-apache/supervisord.conf /etc/supervisord.conf
CMD ["supervisord", "-c /etc/supervisord.conf"]
@@ -0,0 +1,30 @@
[supervisord]
nodaemon=true
user=root
[program:cron]
command=/usr/sbin/cron -f -L 0
autostart=true
autorestart=true
[program:queue]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/monica/artisan queue:work --sleep=10 --timeout=0 --tries=3 --queue=default,migration
numprocs=1
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/proc/1/fd/2
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
startretries=0
[program:apache]
process_name=%(program_name)s_%(process_num)02d
command=/usr/local/bin/apache2-foreground
stdout_logfile=/proc/1/fd/1
stdout_logfile_maxbytes=0
stderr_logfile=/proc/1/fd/2
stderr_logfile_maxbytes=0
autostart=true
autorestart=true