Merge pull request #1 from jkaninda/7.4

7.4
This commit is contained in:
2022-06-17 15:24:25 +02:00
committed by GitHub
5 changed files with 125 additions and 0 deletions

1
.dockerignore Normal file
View File

@@ -0,0 +1 @@
.git

82
Dockerfile Normal file
View File

@@ -0,0 +1,82 @@
FROM php:7.4-fpm
ENV WORKDIR=/var/www
ENV STORAGE_DIR=/var/www/storage
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmemcached-dev \
libzip-dev \
libpng-dev \
libonig-dev \
libxml2-dev \
librdkafka-dev \
libpq-dev \
openssh-server \
zip \
unzip \
supervisor \
sqlite3 \
nano \
cron
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Kafka
RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\
&& cd php-rdkafka \
&& phpize \
&& ./configure \
&& make all -j 5 \
&& make install
# Install PHP extensions zip, mbstring, exif, bcmath, intl
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl
# Install Redis and enable it
RUN pecl install redis && docker-php-ext-enable redis
# Install Rdkafka and enable it
RUN docker-php-ext-enable rdkafka \
&& rm -rf /php-rdkafka
# Install the php memcached extension
RUN pecl install memcached && docker-php-ext-enable memcached
# Install the PHP pdo_mysql extention
RUN docker-php-ext-install pdo_mysql
# Install the PHP pdo_pgsql extention
RUN docker-php-ext-install pdo_pgsql
# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy php.ini file
COPY php/php.ini $PHP_INI_DIR/conf.d/
# Install Laravel Envoy
RUN composer global require "laravel/envoy=~1.0"
#--------------------Add supervisor file in supervisor directory ------------------------------------
ADD worker/supervisord.conf /etc/supervisor/conf.d/worker.conf
# Add crontab file in the cron directory
ADD worker/crontab /etc/cron.d/crontab
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/crontab
# Set working directory
WORKDIR $WORKDIR
RUN usermod -u 1000 www-data
RUN groupmod -g 1000 www-data
EXPOSE 9000
# Run Supervisor
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]

3
php/php.ini Normal file
View File

@@ -0,0 +1,3 @@
upload_max_filesize= 80M
post_max_size= 80M
memory_limit = 1G

2
worker/crontab Normal file
View File

@@ -0,0 +1,2 @@
* * * * * root php /var/www/artisan schedule:run >> /var/log/cron.log 2>&1" >> /etc/crontab
# Don't remove the empty line at the end of this file. It is required to run the cron job

37
worker/supervisord.conf Normal file
View File

@@ -0,0 +1,37 @@
[supervisord]
nodaemon=true
[program:php-fpm]
command=/usr/local/sbin/php-fpm
numprocs=1
autostart=true
autorestart=true
stderr_logfile=/var/log/php-fpm_consumer.err.log
stdout_logfile=/var/log/php-fpm_consumer.out.log
user=root
priority=100
[program:app-scheduler]
process_name=%(program_name)s_%(process_num)02d
command=/bin/sh -c "while [ true ]; do (php /var/www/html/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
autostart=true
autorestart=true
numprocs=1
user=root
redirect_stderr=true
[program:app-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
numprocs=2
user=root
redirect_stderr=true
stdout_logfile=/var/www/storage/logs/worker.log