From a422dbdebd8b387fe26b54e75801567de1f018de Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 12 Jul 2025 07:23:24 -0400 Subject: [PATCH 1/3] refactor: Consolidate supervisord configurations and streamline Dockerfiles for improved service management. --- docker/apache/Dockerfile | 7 ++----- docker/apache/supervisord/conf.d/queue.conf | 9 --------- docker/apache/supervisord/log/.gitignore | 2 -- docker/apache/supervisord/supervisord.conf | 14 -------------- docker/frankenphp/Dockerfile | 7 ++----- docker/frankenphp/supervisord/log/.gitignore | 2 -- docker/frankenphp/supervisord/supervisord.conf | 15 --------------- docker/init.sh | 4 ++++ docker/nginx/Dockerfile | 9 +++------ docker/nginx/supervisord/conf.d/queue.conf | 14 -------------- docker/nginx/supervisord/log/.gitignore | 2 -- .../conf.d/apache2.conf | 6 +++++- .../conf.d/frankenphp.conf | 0 .../supervisord => supervisor}/conf.d/nginx.conf | 0 .../conf.d/php-fpm.conf | 0 .../supervisord => supervisor}/conf.d/queue.conf | 3 --- .../supervisord => supervisor}/supervisord.conf | 4 ++-- 17 files changed, 18 insertions(+), 80 deletions(-) delete mode 100644 docker/apache/supervisord/conf.d/queue.conf delete mode 100644 docker/apache/supervisord/log/.gitignore delete mode 100644 docker/apache/supervisord/supervisord.conf delete mode 100644 docker/frankenphp/supervisord/log/.gitignore delete mode 100644 docker/frankenphp/supervisord/supervisord.conf delete mode 100644 docker/nginx/supervisord/conf.d/queue.conf delete mode 100644 docker/nginx/supervisord/log/.gitignore rename docker/{apache/supervisord => supervisor}/conf.d/apache2.conf (50%) rename docker/{frankenphp/supervisord => supervisor}/conf.d/frankenphp.conf (100%) rename docker/{nginx/supervisord => supervisor}/conf.d/nginx.conf (100%) rename docker/{nginx/supervisord => supervisor}/conf.d/php-fpm.conf (100%) rename docker/{frankenphp/supervisord => supervisor}/conf.d/queue.conf (84%) rename docker/{nginx/supervisord => supervisor}/supervisord.conf (100%) diff --git a/docker/apache/Dockerfile b/docker/apache/Dockerfile index d4979f7..14c3d02 100644 --- a/docker/apache/Dockerfile +++ b/docker/apache/Dockerfile @@ -41,14 +41,11 @@ RUN usermod -u ${USER_ID} www-data && groupmod -g ${GROUP_ID} www-data RUN mkdir -p /var/www/.composer/cache /var/www/.npm && \ chown -R www-data:www-data /var/www/.composer /var/www/.npm -# Copy supervisord config -COPY docker/apache/supervisord/supervisord.conf /etc/supervisor/supervisord.conf - # Copy supervisord program configs -COPY docker/apache/supervisord/conf.d/apache2.conf /etc/supervisor/conf.d/apache2.conf +COPY docker/supervisord/conf.d/apache2.conf /etc/supervisor/conf.d/apache2.conf # Copy queue worker config uncommented for use with yii2-queue -#COPY docker/apache/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf +#COPY docker/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf # Copy scripts COPY docker/init.sh /usr/local/bin/init.sh diff --git a/docker/apache/supervisord/conf.d/queue.conf b/docker/apache/supervisord/conf.d/queue.conf deleted file mode 100644 index 5ee7012..0000000 --- a/docker/apache/supervisord/conf.d/queue.conf +++ /dev/null @@ -1,9 +0,0 @@ -[program:yii-queue-worker] -process_name=%(program_name)s_%(process_num)02d -command=/usr/local/bin/php /app/yii queue/listen --verbose=1 --color=0 -autostart=true -autorestart=true -user=www-data -numprocs=4 -redirect_stderr=true -stdout_logfile=/app/docker/apache/supervisord/log/yii-queue-worker.log diff --git a/docker/apache/supervisord/log/.gitignore b/docker/apache/supervisord/log/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/docker/apache/supervisord/log/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/docker/apache/supervisord/supervisord.conf b/docker/apache/supervisord/supervisord.conf deleted file mode 100644 index f2bbee4..0000000 --- a/docker/apache/supervisord/supervisord.conf +++ /dev/null @@ -1,14 +0,0 @@ -[supervisord] -logfile = /proc/self/fd/1 -logfile_maxbytes = 0 -loglevel = info -pidfile = /var/run/supervisord.pid -nodaemon = true -user = root -silent = true - -[include] -files = /etc/supervisor/conf.d/*.conf - -[supervisorctl] -serverurl = unix:///var/run/supervisor.sock diff --git a/docker/frankenphp/Dockerfile b/docker/frankenphp/Dockerfile index 8a59f2b..e2fd102 100644 --- a/docker/frankenphp/Dockerfile +++ b/docker/frankenphp/Dockerfile @@ -51,14 +51,11 @@ RUN usermod -u ${USER_ID} www-data && groupmod -g ${GROUP_ID} www-data RUN mkdir -p /var/www/.composer/cache /var/www/.npm && \ chown -R www-data:www-data /var/www/.composer /var/www/.npm -# Copy supervisord config -COPY docker/frankenphp/supervisord/supervisord.conf /etc/supervisor/supervisord.conf - # Copy supervisord program configs -COPY docker/frankenphp/supervisord/conf.d/frankenphp.conf /etc/supervisor/conf.d/frankenphp.conf +COPY docker/supervisord/conf.d/frankenphp.conf /etc/supervisor/conf.d/frankenphp.conf # Copy queue worker config uncommented for use with yii2-queue -#COPY docker/frankenphp/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf +#COPY docker/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf # Copy scripts COPY docker/init.sh /usr/local/bin/init.sh diff --git a/docker/frankenphp/supervisord/log/.gitignore b/docker/frankenphp/supervisord/log/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/docker/frankenphp/supervisord/log/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/docker/frankenphp/supervisord/supervisord.conf b/docker/frankenphp/supervisord/supervisord.conf deleted file mode 100644 index 694dd21..0000000 --- a/docker/frankenphp/supervisord/supervisord.conf +++ /dev/null @@ -1,15 +0,0 @@ -[supervisord] -nodaemon=true -logfile=/dev/stdout -logfile_maxbytes=0 -pidfile=/var/run/supervisord.pid - -[include] -files = /etc/supervisor/conf.d/*.conf - -[supervisorctl] -serverurl=unix:///var/run/supervisor.sock - -[unix_http_server] -file=/var/run/supervisor.sock -chmod=0700 diff --git a/docker/init.sh b/docker/init.sh index b51c625..57832c2 100644 --- a/docker/init.sh +++ b/docker/init.sh @@ -84,6 +84,10 @@ if [ -f "/app/composer.json" ] && [ ! -d "/app/vendor" ]; then echo -e "${GREEN}✓ Composer dependencies installed successfully${NC}" fi +# Copy supervisord configuration +echo -e "${YELLOW}Configuring supervisord...${NC}" +cp /app/docker/supervisord/supervisord.conf /etc/supervisor/supervisord.conf + echo -e "${GREEN}Starting supervisord...${NC}" # Start supervisord diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index 03bf54f..01a449d 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -36,15 +36,12 @@ RUN usermod -u ${USER_ID} www-data && groupmod -g ${GROUP_ID} www-data RUN mkdir -p /var/www/.composer/cache /var/www/.npm && \ chown -R www-data:www-data /var/www/.composer /var/www/.npm -# Copy supervisord config -COPY docker/nginx/supervisord/supervisord.conf /etc/supervisor/supervisord.conf - # Copy supervisord program configs -COPY docker/nginx/supervisord/conf.d/nginx.conf /etc/supervisor/conf.d/nginx.conf -COPY docker/nginx/supervisord/conf.d/php-fpm.conf /etc/supervisor/conf.d/php-fpm.conf +COPY docker/supervisord/conf.d/nginx.conf /etc/supervisor/conf.d/nginx.conf +COPY docker/supervisord/conf.d/php-fpm.conf /etc/supervisor/conf.d/php-fpm.conf # Copy queue worker config uncommented for use with yii2-queue -#COPY docker/nginx/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf +#COPY docker/supervisord/conf.d/queue.conf /etc/supervisor/conf.d/queue.conf # Copy scripts COPY docker/init.sh /usr/local/bin/init.sh diff --git a/docker/nginx/supervisord/conf.d/queue.conf b/docker/nginx/supervisord/conf.d/queue.conf deleted file mode 100644 index b27b6bb..0000000 --- a/docker/nginx/supervisord/conf.d/queue.conf +++ /dev/null @@ -1,14 +0,0 @@ -[program:yii-queue-worker] -process_name=%(program_name)s_%(process_num)02d -command=/usr/local/bin/php /app/yii queue/listen --verbose=1 --color=0 -autorestart=true -autostart=true -killasgroup=true -numprocs=4 -redirect_stderr=true -stderr_logfile=/dev/stderr -stderr_logfile_maxbytes=0 -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 -stopasgroup=true -user=www-data diff --git a/docker/nginx/supervisord/log/.gitignore b/docker/nginx/supervisord/log/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/docker/nginx/supervisord/log/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/docker/apache/supervisord/conf.d/apache2.conf b/docker/supervisor/conf.d/apache2.conf similarity index 50% rename from docker/apache/supervisord/conf.d/apache2.conf rename to docker/supervisor/conf.d/apache2.conf index 0d42f1e..780bf67 100644 --- a/docker/apache/supervisord/conf.d/apache2.conf +++ b/docker/supervisor/conf.d/apache2.conf @@ -1,4 +1,8 @@ [program:apache2] command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" +autorestart=true autostart=true -autorestart=true \ No newline at end of file +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 diff --git a/docker/frankenphp/supervisord/conf.d/frankenphp.conf b/docker/supervisor/conf.d/frankenphp.conf similarity index 100% rename from docker/frankenphp/supervisord/conf.d/frankenphp.conf rename to docker/supervisor/conf.d/frankenphp.conf diff --git a/docker/nginx/supervisord/conf.d/nginx.conf b/docker/supervisor/conf.d/nginx.conf similarity index 100% rename from docker/nginx/supervisord/conf.d/nginx.conf rename to docker/supervisor/conf.d/nginx.conf diff --git a/docker/nginx/supervisord/conf.d/php-fpm.conf b/docker/supervisor/conf.d/php-fpm.conf similarity index 100% rename from docker/nginx/supervisord/conf.d/php-fpm.conf rename to docker/supervisor/conf.d/php-fpm.conf diff --git a/docker/frankenphp/supervisord/conf.d/queue.conf b/docker/supervisor/conf.d/queue.conf similarity index 84% rename from docker/frankenphp/supervisord/conf.d/queue.conf rename to docker/supervisor/conf.d/queue.conf index b27b6bb..b8eba53 100644 --- a/docker/frankenphp/supervisord/conf.d/queue.conf +++ b/docker/supervisor/conf.d/queue.conf @@ -3,12 +3,9 @@ process_name=%(program_name)s_%(process_num)02d command=/usr/local/bin/php /app/yii queue/listen --verbose=1 --color=0 autorestart=true autostart=true -killasgroup=true numprocs=4 -redirect_stderr=true stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 -stopasgroup=true user=www-data diff --git a/docker/nginx/supervisord/supervisord.conf b/docker/supervisor/supervisord.conf similarity index 100% rename from docker/nginx/supervisord/supervisord.conf rename to docker/supervisor/supervisord.conf index f2bbee4..d209121 100644 --- a/docker/nginx/supervisord/supervisord.conf +++ b/docker/supervisor/supervisord.conf @@ -2,10 +2,10 @@ logfile = /proc/self/fd/1 logfile_maxbytes = 0 loglevel = info -pidfile = /var/run/supervisord.pid nodaemon = true -user = root +pidfile = /var/run/supervisord.pid silent = true +user = root [include] files = /etc/supervisor/conf.d/*.conf From 8186f75fe1f39b6be2376909750e789eaf3726a9 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 12 Jul 2025 07:25:31 -0400 Subject: [PATCH 2/3] feat: Add supervisord configuration files for Apache, Nginx, PHP-FPM, and queue worker to manage services in Docker. --- docker/{supervisor => supervisord}/conf.d/apache2.conf | 0 docker/{supervisor => supervisord}/conf.d/frankenphp.conf | 0 docker/{supervisor => supervisord}/conf.d/nginx.conf | 0 docker/{supervisor => supervisord}/conf.d/php-fpm.conf | 0 docker/{supervisor => supervisord}/conf.d/queue.conf | 0 docker/{supervisor => supervisord}/supervisord.conf | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename docker/{supervisor => supervisord}/conf.d/apache2.conf (100%) rename docker/{supervisor => supervisord}/conf.d/frankenphp.conf (100%) rename docker/{supervisor => supervisord}/conf.d/nginx.conf (100%) rename docker/{supervisor => supervisord}/conf.d/php-fpm.conf (100%) rename docker/{supervisor => supervisord}/conf.d/queue.conf (100%) rename docker/{supervisor => supervisord}/supervisord.conf (100%) diff --git a/docker/supervisor/conf.d/apache2.conf b/docker/supervisord/conf.d/apache2.conf similarity index 100% rename from docker/supervisor/conf.d/apache2.conf rename to docker/supervisord/conf.d/apache2.conf diff --git a/docker/supervisor/conf.d/frankenphp.conf b/docker/supervisord/conf.d/frankenphp.conf similarity index 100% rename from docker/supervisor/conf.d/frankenphp.conf rename to docker/supervisord/conf.d/frankenphp.conf diff --git a/docker/supervisor/conf.d/nginx.conf b/docker/supervisord/conf.d/nginx.conf similarity index 100% rename from docker/supervisor/conf.d/nginx.conf rename to docker/supervisord/conf.d/nginx.conf diff --git a/docker/supervisor/conf.d/php-fpm.conf b/docker/supervisord/conf.d/php-fpm.conf similarity index 100% rename from docker/supervisor/conf.d/php-fpm.conf rename to docker/supervisord/conf.d/php-fpm.conf diff --git a/docker/supervisor/conf.d/queue.conf b/docker/supervisord/conf.d/queue.conf similarity index 100% rename from docker/supervisor/conf.d/queue.conf rename to docker/supervisord/conf.d/queue.conf diff --git a/docker/supervisor/supervisord.conf b/docker/supervisord/supervisord.conf similarity index 100% rename from docker/supervisor/supervisord.conf rename to docker/supervisord/supervisord.conf From 8f381cc1e045733a4c384a6b83c2243327b809e1 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sat, 12 Jul 2025 07:30:01 -0400 Subject: [PATCH 3/3] refactor: Enhance supervisord configuration handling with error checking for missing file. --- docker/init.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/init.sh b/docker/init.sh index 57832c2..743ba97 100644 --- a/docker/init.sh +++ b/docker/init.sh @@ -86,7 +86,14 @@ fi # Copy supervisord configuration echo -e "${YELLOW}Configuring supervisord...${NC}" -cp /app/docker/supervisord/supervisord.conf /etc/supervisor/supervisord.conf + +if [ -f "/app/docker/supervisord/supervisord.conf" ]; then + cp /app/docker/supervisord/supervisord.conf /etc/supervisor/supervisord.conf + echo -e "${GREEN}✓ Supervisord configuration copied successfully${NC}" +else + echo -e "${RED}✗ Error: Supervisord configuration file not found${NC}" + exit 1 +fi echo -e "${GREEN}Starting supervisord...${NC}"