From f2aa4ef44917ac6b3077c2208fb687b76404bd7c Mon Sep 17 00:00:00 2001 From: MrAnyx Date: Fri, 3 Jan 2025 23:46:09 +0000 Subject: [PATCH] fix: Replace supervisor with S6-Overlay for process management in entrypoint scripts and Dockerfile --- .docker/entrypoint.dev.sh | 9 ++------- .docker/entrypoint.prod.sh | 9 ++------- .docker/s6/apache/run | 6 ++++++ .docker/s6/messenger/run | 6 ++++++ Dockerfile | 8 ++++++-- 5 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 .docker/s6/apache/run create mode 100644 .docker/s6/messenger/run diff --git a/.docker/entrypoint.dev.sh b/.docker/entrypoint.dev.sh index e52d218..bbd4f37 100644 --- a/.docker/entrypoint.dev.sh +++ b/.docker/entrypoint.dev.sh @@ -2,10 +2,5 @@ set -e # Update and start supervisor service -echo "Starting supervisor..." -service supervisor start -supervisorctl reread -supervisorctl update -supervisorctl restart all - -exec docker-php-entrypoint "$@" +echo "Starting S6-Overlay..." +exec /init diff --git a/.docker/entrypoint.prod.sh b/.docker/entrypoint.prod.sh index 2b320e6..cb7c55f 100644 --- a/.docker/entrypoint.prod.sh +++ b/.docker/entrypoint.prod.sh @@ -6,10 +6,5 @@ echo "Running database migrations..." php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration # Update and start supervisor service -echo "Starting supervisor..." -service supervisor start -supervisorctl reread -supervisorctl update -supervisorctl restart all - -exec docker-php-entrypoint "$@" +echo "Starting S6-Overlay..." +exec /init diff --git a/.docker/s6/apache/run b/.docker/s6/apache/run new file mode 100644 index 0000000..4462607 --- /dev/null +++ b/.docker/s6/apache/run @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv sh +set -e + +echo "Starting apache2" +exec apache2-foreground +echo "apache2 has been started" diff --git a/.docker/s6/messenger/run b/.docker/s6/messenger/run new file mode 100644 index 0000000..134b04c --- /dev/null +++ b/.docker/s6/messenger/run @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv sh +set -e + +echo "Starting messenger:consume async" +php /var/www/html/bin/console messenger:consume async --time-limit=3600 +echo "messenger:consume async has started" diff --git a/Dockerfile b/Dockerfile index 00d283b..8af9ac7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,10 @@ FROM php:8.3.15-apache AS base -RUN apt-get update && apt-get install -y supervisor +RUN apt-get update +ARG S6_OVERLAY_VERSION=3.2.0.3 +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp +RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz WORKDIR /var/www/html ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ RUN install-php-extensions intl @@ -10,7 +15,6 @@ RUN install-php-extensions @composer ENV COMPOSER_ALLOW_SUPERUSER=1 COPY ./.docker/apache/apache.conf /etc/apache2/sites-available/000-default.conf RUN a2enmod rewrite -COPY ./.docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] FROM base AS dev