Laravel 第一版問題修正

Laraval 第一版拆串queue
20250602
This commit is contained in:
allen.yan 2025-06-02 11:55:42 +08:00
parent b0e44bee17
commit 9a89e4dffc
6 changed files with 44 additions and 13 deletions

View File

@ -20,9 +20,8 @@ RUN chown -R www-data:www-data /var/www/html
WORKDIR /var/www/html WORKDIR /var/www/html
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY ./docker/entrypoint.sh /entrypoint.sh COPY ./docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]
CMD ["supervisord", "-n", "-c", "/etc/supervisor/conf.d/supervisord.conf"] CMD ["docker-php-entrypoint", "php-fpm"]

16
Dockerfile.queue Normal file
View File

@ -0,0 +1,16 @@
FROM php:8.3-fpm
# 安裝必要套件與 PHP 擴充
RUN apt-get update && apt-get install -y \
git unzip zip curl libzip-dev libonig-dev libxml2-dev && \
docker-php-ext-install pdo_mysql zip bcmath
COPY ./data/KTVCentral/ /var/www/html/
RUN chown -R www-data:www-data /var/www/html
WORKDIR /var/www/html
COPY ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["supervisord", "-n", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

View File

@ -53,6 +53,16 @@ services:
NGINX_PORT: ${APP_PORT} NGINX_PORT: ${APP_PORT}
networks: networks:
- app_network - app_network
queue:
build:
context: .
dockerfile: Dockerfile.queue
volumes:
- ./data/KTVCentral:/var/www/html
depends_on:
- nginx
networks:
- app_network
networks: networks:
app_network: app_network:
name: ${APP_NAME}_network name: ${APP_NAME}_network

View File

@ -54,4 +54,8 @@ echo "Installing npm packages..."
echo "Building front-end assets..." echo "Building front-end assets..."
npm run build npm run build
echo "Setting permissions for storage and bootstrap/cache..."
chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
exec "$@" exec "$@"

View File

@ -14,10 +14,20 @@ server {
location ~ \.php$ { location ~ \.php$ {
include fastcgi_params; include fastcgi_params;
fastcgi_pass app:9000; fastcgi_pass app:9000;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
# Laravel 正確位置
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# Optional: 支援 PATH_INFO
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
# 避免 NGINX 直接 cache
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
} }
location ~ /\.ht { location ~ /\.ht {

View File

@ -3,20 +3,12 @@ nodaemon=true
logfile=/var/www/logs/supervisord.log ; 設定 log 儲存位置 logfile=/var/www/logs/supervisord.log ; 設定 log 儲存位置
pidfile=/var/www/logs/supervisord.pid ; 設定 pid 儲存位置 pidfile=/var/www/logs/supervisord.pid ; 設定 pid 儲存位置
[program:php-fpm]
command=docker-php-entrypoint php-fpm
autostart=true
autorestart=true
priority=1
stdout_logfile=/var/www/logs/php-fpm.log
stderr_logfile=/var/www/logs/php-fpm.err.log
[program:queue-worker] [program:queue-worker]
directory=/var/www/html directory=/var/www/html
command=php artisan queue:work --daemon --timeout=3600 --tries=1 --queue=default command=php artisan queue:work --daemon --timeout=3600 --tries=1 --queue=default
autostart=true autostart=true
autorestart=true autorestart=true
priority=2 priority=1
stdout_logfile=/var/www/logs/queue.log stdout_logfile=/var/www/logs/queue.log
stderr_logfile=/var/www/logs/queue_error.log stderr_logfile=/var/www/logs/queue_error.log
@ -25,6 +17,6 @@ directory=/var/www/html
command=sh -c "while true; do php artisan schedule:run; sleep 60; done" command=sh -c "while true; do php artisan schedule:run; sleep 60; done"
autostart=true autostart=true
autorestart=true autorestart=true
priority=3 priority=2
stdout_logfile=/var/www/logs/schedule.log stdout_logfile=/var/www/logs/schedule.log
stderr_logfile=/var/www/logs/schedule_error.log stderr_logfile=/var/www/logs/schedule_error.log