From: fomichev Date: Sun, 8 Dec 2024 21:26:03 +0000 (+0300) Subject: Добавляем контейнер супервайзера X-Git-Tag: 1.7~67^2~12^2~1 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=bf9dac41350bf85f063517f721f566701fcff8a1;p=erp24_rep%2Fyii-erp24%2F.git Добавляем контейнер супервайзера --- diff --git a/docker-compose.yml b/docker-compose.yml index 5f79ffea..c7cb57e0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -80,6 +80,22 @@ services: - ./erp24:/www - ./docker/php/conf/php-fpm.conf:/usr/local/etc/php-fpm.conf - ./docker/php/conf/php.ini:/usr/local/etc/php/php.ini + queue-yii_erp24: + build: + context: ./docker/supervisor + dockerfile: Dockerfile + restart: always + depends_on: + - rabbitmq-yii_erp24 + env_file: + - docker/php/dev.php.env + - docker/db/dev.db-pgsql.env + environment: + MODE: 'dev' + volumes: + - ./erp24:/www + - ./docker/supervisor/conf/supervisord.conf:/etc/supervisor/supervisord.conf + - ./docker/supervisor/conf/queue-worker.conf:/etc/supervisor/conf.d/queue-worker.conf db-yii_erp24: build: ./docker/db restart: always diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 22dbf8b1..e29ab02d 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -18,7 +18,6 @@ RUN docker-php-ext-install pdo_pgsql RUN docker-php-ext-install bcmath sockets RUN docker-php-ext-enable bcmath sockets - #add composer RUN wget https://getcomposer.org/installer \ && php installer \ @@ -43,24 +42,6 @@ RUN apk add --no-cache --update --virtual .build-deps \ && docker-php-ext-enable xdebug \ && apk del .build-deps -# Установка Supervisor -#RUN apk add --no-cache supervisor - -# Создаем каталог для логов Supervisor -#RUN mkdir -p /var/log/supervisor - -# Копирование скрипта ожидания RabbitMQ -#COPY /conf/wait-for-rabbitmq.sh /usr/local/bin/wait-for-rabbitmq -#RUN chmod +x /usr/local/bin/wait-for-rabbitmq - -# Копирование конфигурации Supervisor -#COPY /conf/supervisord.conf /etc/supervisor/supervisord.conf -#COPY /conf/supervisor-conf.d/ /etc/supervisor/conf.d/ - - # Set working directory WORKDIR /www -# Установка CMD для запуска Supervisor через скрипт ожидания -#CMD ["/usr/local/bin/wait-for-rabbitmq", "supervisord", "-c", "/etc/supervisor/supervisord.conf"] -#CMD ["/usr/local/bin/wait-for-rabbitmq", "php", "/www/yii", "queue/listen"] \ No newline at end of file diff --git a/docker/php/conf/supervisor-conf.d/yii-queue.conf b/docker/php/conf/supervisor-conf.d/yii-queue.conf deleted file mode 100644 index 5c3195eb..00000000 --- a/docker/php/conf/supervisor-conf.d/yii-queue.conf +++ /dev/null @@ -1,11 +0,0 @@ -[program:yii-queue] -command=php /www/yii queue/listen -directory=/www -autostart=true -autorestart=true -stderr_logfile=/var/log/supervisor/yii-queue.err.log -stdout_logfile=/var/log/supervisor/yii-queue.out.log -numprocs=1 -user=www-data -stopasgroup=true -killasgroup=true \ No newline at end of file diff --git a/docker/php/conf/supervisord.conf b/docker/php/conf/supervisord.conf deleted file mode 100644 index 5f59ff3a..00000000 --- a/docker/php/conf/supervisord.conf +++ /dev/null @@ -1,11 +0,0 @@ -[supervisord] -nodaemon=true -logfile=/var/log/supervisor/supervisord.log -logfile_maxbytes=50MB -logfile_backups=10 -loglevel=info -pidfile=/var/run/supervisord.pid -childlogdir=/var/log/supervisor - -[include] -files = /etc/supervisor/conf.d/*.conf \ No newline at end of file diff --git a/docker/php/conf/wait-for-rabbitmq.sh b/docker/php/conf/wait-for-rabbitmq.sh deleted file mode 100644 index 7ef901c0..00000000 --- a/docker/php/conf/wait-for-rabbitmq.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -echo "Waiting for RabbitMQ to start..." -until nc -z rabbitmq-yii_erp24 5672; do - echo "RabbitMQ is unavailable - sleeping" - sleep 2 -done - -echo "RabbitMQ is up - executing command" -exec "$@" \ No newline at end of file diff --git a/docker/supervisor/Dockerfile b/docker/supervisor/Dockerfile new file mode 100644 index 00000000..cbb52234 --- /dev/null +++ b/docker/supervisor/Dockerfile @@ -0,0 +1,13 @@ +FROM php:8.1-cli-alpine + +# Установка Supervisor +RUN apk add --no-cache supervisor bash +RUN mkdir -p /var/log/supervisor +# Копирование конфигурации +COPY ./conf/supervisord.conf /etc/supervisor/supervisord.conf +COPY ./conf/queue-worker.conf /etc/supervisor/conf.d/queue-worker.conf + +# Установка рабочей директории +WORKDIR /www + +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] \ No newline at end of file diff --git a/docker/supervisor/conf/queue-worker.conf b/docker/supervisor/conf/queue-worker.conf new file mode 100644 index 00000000..beea3715 --- /dev/null +++ b/docker/supervisor/conf/queue-worker.conf @@ -0,0 +1,6 @@ +[program:yii-queue] +command=/usr/local/bin/php /www/yii queue/listen --verbose +autostart=true +autorestart=true +stderr_logfile=/var/log/supervisor/yii-queue.err.log +stdout_logfile=/var/log/supervisor/yii-queue.out.log \ No newline at end of file diff --git a/docker/supervisor/conf/supervisord.conf b/docker/supervisor/conf/supervisord.conf new file mode 100644 index 00000000..1ee77584 --- /dev/null +++ b/docker/supervisor/conf/supervisord.conf @@ -0,0 +1,7 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisor/supervisord.log +pidfile=/var/run/supervisord.pid + +[include] +files = /etc/supervisor/conf.d/*.conf \ No newline at end of file