mirror of
https://github.com/jkaninda/laravel-php-fpm.git
synced 2025-12-06 00:49:39 +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:
|
||||
### Open php-fpm
|
||||
```sh
|
||||
docker-compose exec php-fpm /bin/bash
|
||||
docker compose exec php-fpm /bin/bash
|
||||
|
||||
```
|
||||
|
||||
Default web root:
|
||||
```
|
||||
/var/www/html
|
||||
```
|
||||
## Configurations
|
||||
|
||||
### Laravel migration
|
||||
```sh
|
||||
php atisan migrate
|
||||
- Superfisor config folder: /etc/supervisor/conf.d/
|
||||
- PHP ini config foler /usr/local/etc/php/conf.d/
|
||||
|
||||
```
|
||||
## Example Laravel-php-fpm with nginx:
|
||||
### docker-compose.yml
|
||||
```yml
|
||||
@@ -192,6 +187,7 @@ volumes:
|
||||
|
||||
```
|
||||
## Build from base
|
||||
|
||||
Dockerfile
|
||||
```Dockerfile
|
||||
FROM jkaninda/laravel-php-fpm:8.3
|
||||
@@ -212,7 +208,8 @@ RUN chown -R www-data:www-data /var/www/html
|
||||
```
|
||||
## Supervisord
|
||||
### 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.
|
||||
|
||||
@@ -235,7 +232,7 @@ stdout_logfile=/var/www/html/storage/logs/kafka.log
|
||||
|
||||
### Storage permision issue
|
||||
```sh
|
||||
docker-compose exec php-fpm /bin/bash
|
||||
docker compose exec php-fpm /bin/bash
|
||||
```
|
||||
|
||||
```sh
|
||||
|
||||
@@ -92,7 +92,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||
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
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
@@ -92,7 +92,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||
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
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
@@ -93,7 +93,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||
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
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
@@ -93,7 +93,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||
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
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
@@ -95,7 +95,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||
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
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
@@ -95,7 +95,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||
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
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
@@ -96,7 +96,8 @@ RUN groupmod -g ${USER_ID} ${GROUP_NAME}
|
||||
RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \
|
||||
chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \
|
||||
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
|
||||
CMD [ "entrypoint" ]
|
||||
|
||||
@@ -51,15 +51,6 @@ else
|
||||
info "artisan file not found"
|
||||
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
|
||||
if [ -f /var/www/html/conf/php/php.ini ]; then
|
||||
cp /var/www/html/conf/php/php.ini $PHP_INI_DIR/conf.d/
|
||||
@@ -70,4 +61,3 @@ else
|
||||
fi
|
||||
|
||||
supervisord -c /etc/supervisor/supervisord.conf
|
||||
#exec "$@"
|
||||
@@ -1,16 +1,20 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
#user=root
|
||||
user=%(ENV_USER_NAME)s
|
||||
logfile=/var/log/supervisor/supervisord.log
|
||||
logfile_maxbytes = 50MB
|
||||
pidfile=/tmp/supervisord.pid
|
||||
directory = /tmp
|
||||
|
||||
[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
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/dev/stdout
|
||||
stderr_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
user=www-data
|
||||
priority=1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user