diff --git a/Dockerfile b/Dockerfile index b846f21..f7277e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,6 @@ FROM nginx:alpine COPY nginx.conf /etc/nginx/nginx.conf +COPY conf.d/ /etc/nginx/conf.d/ +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +CMD ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..7fa4b25 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +if [ "$IS_PRODUCT" = "true" ]; then + cp /etc/nginx/conf.d/frontend.product.conf /etc/nginx/conf.d/frontend.conf + echo "nginx: production mode (static files from /var/www/html)" + i=0 + while [ ! -f /var/www/html/index.html ]; do + i=$((i + 1)) + if [ "$i" -gt 120 ]; then + echo "nginx: WARNING: /var/www/html/index.html not found after 240s" + break + fi + sleep 2 + done +else + cp /etc/nginx/conf.d/frontend.dev.conf /etc/nginx/conf.d/frontend.conf + echo "nginx: development mode (proxy to frontend:5173)" +fi + +exec nginx -g 'daemon off;' diff --git a/nginx.conf b/nginx.conf index 8b8b021..bc77cae 100644 --- a/nginx.conf +++ b/nginx.conf @@ -12,14 +12,64 @@ server backend:8000; } - upstream frontend { - server frontend:5173; - } - server { listen 80; server_name _; + # CRM 法人番号インポート: 大容量アップロード・長時間処理(クエリは location 対象外) + location /api/plugins/crm/corporate-numbers/import { + client_max_body_size 2g; + client_body_timeout 1800s; + proxy_pass http://backend; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_connect_timeout 1800s; + proxy_send_timeout 1800s; + proxy_read_timeout 1800s; + send_timeout 1800s; + } + + # CRM 郵便番号インポート: 最大 100MB・長時間処理(クエリは location 対象外) + location /api/plugins/crm/postal-codes/import { + client_max_body_size 100m; + client_body_timeout 1800s; + proxy_pass http://backend; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_connect_timeout 1800s; + proxy_send_timeout 1800s; + proxy_read_timeout 1800s; + send_timeout 1800s; + } + + # CRM 請求書インポート: 最大 100MB・長時間処理(クエリは location 対象外) + location /api/plugins/crm/invoices/import { + client_max_body_size 100m; + client_body_timeout 1800s; + proxy_pass http://backend; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_connect_timeout 1800s; + proxy_send_timeout 1800s; + proxy_read_timeout 1800s; + send_timeout 1800s; + } + location /api/ { proxy_pass http://backend; proxy_http_version 1.1; @@ -56,15 +106,6 @@ proxy_set_header X-Forwarded-Proto $scheme; } - location / { - proxy_pass http://frontend; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } + include /etc/nginx/conf.d/frontend.conf; } }