mirror of
https://github.com/jkaninda/laravel-php-fpm.git
synced 2025-12-06 08:59:38 +01:00
Merge pull request #75 from jkaninda/develop
chore: redirect php-fpm process to supervisor's log, refactoring of code
This commit is contained in:
19
README.md
19
README.md
@@ -70,20 +70,15 @@ services:
|
|||||||
## Laravel `artisan` command usage:
|
## Laravel `artisan` command usage:
|
||||||
### Open php-fpm
|
### Open php-fpm
|
||||||
```sh
|
```sh
|
||||||
docker-compose exec php-fpm /bin/bash
|
docker compose exec php-fpm /bin/bash
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Default web root:
|
## Configurations
|
||||||
```
|
|
||||||
/var/www/html
|
|
||||||
```
|
|
||||||
|
|
||||||
### Laravel migration
|
- Superfisor config folder: /etc/supervisor/conf.d/
|
||||||
```sh
|
- PHP ini config foler /usr/local/etc/php/conf.d/
|
||||||
php atisan migrate
|
|
||||||
|
|
||||||
```
|
|
||||||
## Example Laravel-php-fpm with nginx:
|
## Example Laravel-php-fpm with nginx:
|
||||||
### docker-compose.yml
|
### docker-compose.yml
|
||||||
```yml
|
```yml
|
||||||
@@ -192,6 +187,7 @@ volumes:
|
|||||||
|
|
||||||
```
|
```
|
||||||
## Build from base
|
## Build from base
|
||||||
|
|
||||||
Dockerfile
|
Dockerfile
|
||||||
```Dockerfile
|
```Dockerfile
|
||||||
FROM jkaninda/laravel-php-fpm:8.3
|
FROM jkaninda/laravel-php-fpm:8.3
|
||||||
@@ -212,7 +208,8 @@ RUN chown -R www-data:www-data /var/www/html
|
|||||||
```
|
```
|
||||||
## Supervisord
|
## Supervisord
|
||||||
### Add supervisor process in
|
### Add supervisor process in
|
||||||
> /var/www/html/conf/worker/supervisor.conf
|
|
||||||
|
> /etc/supervisor/conf.d/
|
||||||
|
|
||||||
In case you want to execute and maintain a task or process with supervisor.
|
In case you want to execute and maintain a task or process with supervisor.
|
||||||
|
|
||||||
@@ -235,7 +232,7 @@ stdout_logfile=/var/www/html/storage/logs/kafka.log
|
|||||||
|
|
||||||
### Storage permision issue
|
### Storage permision issue
|
||||||
```sh
|
```sh
|
||||||
docker-compose exec php-fpm /bin/bash
|
docker compose exec php-fpm /bin/bash
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
|||||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/
|
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
|
||||||
|
chown -R ${USER_NAME}:${GROUP_NAME} /tmp
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
CMD [ "entrypoint" ]
|
CMD [ "entrypoint" ]
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
|||||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/
|
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
|
||||||
|
chown -R ${USER_NAME}:${GROUP_NAME} /tmp
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
CMD [ "entrypoint" ]
|
CMD [ "entrypoint" ]
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
|||||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/
|
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
|
||||||
|
chown -R ${USER_NAME}:${GROUP_NAME} /tmp
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
CMD [ "entrypoint" ]
|
CMD [ "entrypoint" ]
|
||||||
|
|||||||
@@ -93,7 +93,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
|||||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/
|
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
|
||||||
|
chown -R ${USER_NAME}:${GROUP_NAME} /tmp
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
CMD [ "entrypoint" ]
|
CMD [ "entrypoint" ]
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
|||||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/
|
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
|
||||||
|
chown -R ${USER_NAME}:${GROUP_NAME} /tmp
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
CMD [ "entrypoint" ]
|
CMD [ "entrypoint" ]
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
|||||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/
|
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
|
||||||
|
chown -R ${USER_NAME}:${GROUP_NAME} /tmp
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
CMD [ "entrypoint" ]
|
CMD [ "entrypoint" ]
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
|||||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \
|
||||||
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/
|
chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \
|
||||||
|
chown -R ${USER_NAME}:${GROUP_NAME} /tmp
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
CMD [ "entrypoint" ]
|
CMD [ "entrypoint" ]
|
||||||
|
|||||||
@@ -51,15 +51,6 @@ else
|
|||||||
info "artisan file not found"
|
info "artisan file not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Check if the supervisor config file exists
|
|
||||||
if [ -f /var/www/html/conf/worker/supervisor.conf ]; then
|
|
||||||
info "additional supervisor config found"
|
|
||||||
cp /var/www/html/conf/worker/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
|
|
||||||
else
|
|
||||||
info "Supervisor.conf not found"
|
|
||||||
info "If you want to add more supervisor configs, create config file in /var/www/html/conf/worker/supervisor.conf"
|
|
||||||
info "Start supervisor with default config..."
|
|
||||||
fi
|
|
||||||
## Check if php.ini file exists
|
## Check if php.ini file exists
|
||||||
if [ -f /var/www/html/conf/php/php.ini ]; then
|
if [ -f /var/www/html/conf/php/php.ini ]; then
|
||||||
cp /var/www/html/conf/php/php.ini $PHP_INI_DIR/conf.d/
|
cp /var/www/html/conf/php/php.ini $PHP_INI_DIR/conf.d/
|
||||||
@@ -70,4 +61,3 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
supervisord -c /etc/supervisor/supervisord.conf
|
supervisord -c /etc/supervisor/supervisord.conf
|
||||||
#exec "$@"
|
|
||||||
@@ -1,16 +1,20 @@
|
|||||||
[supervisord]
|
[supervisord]
|
||||||
nodaemon=true
|
nodaemon=true
|
||||||
#user=root
|
|
||||||
user=%(ENV_USER_NAME)s
|
user=%(ENV_USER_NAME)s
|
||||||
logfile=/var/log/supervisor/supervisord.log
|
logfile=/var/log/supervisor/supervisord.log
|
||||||
|
logfile_maxbytes = 50MB
|
||||||
|
pidfile=/tmp/supervisord.pid
|
||||||
|
directory = /tmp
|
||||||
|
|
||||||
[program:php-fpm]
|
[program:php-fpm]
|
||||||
command=/usr/local/sbin/php-fpm
|
command=/usr/local/sbin/php-fpm
|
||||||
numprocs=1
|
numprocs=1
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
stderr_logfile=/var/log/php-fpm_consumer.err.log
|
redirect_stderr=true
|
||||||
stdout_logfile=/var/log/php-fpm_consumer.out.log
|
stdout_logfile=/dev/stdout
|
||||||
|
stderr_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
user=www-data
|
user=www-data
|
||||||
priority=1
|
priority=1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user