不知名提交
This commit is contained in:
74
docker/default.conf
Normal file
74
docker/default.conf
Normal file
@@ -0,0 +1,74 @@
|
||||
server {
|
||||
listen 2323;
|
||||
server_name _;
|
||||
|
||||
# 前端静态文件根目录
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# 日志配置
|
||||
access_log /app/data/logs/access.log;
|
||||
error_log /app/data/logs/error.log;
|
||||
|
||||
# API 请求转发到后端
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:5002;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header 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_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 300s;
|
||||
proxy_connect_timeout 300s;
|
||||
}
|
||||
|
||||
# 60sapi 静态文件路由
|
||||
location /60sapi/ {
|
||||
alias /usr/share/nginx/html/60sapi/;
|
||||
try_files $uri $uri/ =404;
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
}
|
||||
|
||||
# smallgame 静态文件路由
|
||||
location /smallgame/ {
|
||||
alias /usr/share/nginx/html/smallgame/;
|
||||
try_files $uri $uri/ =404;
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
}
|
||||
|
||||
# aimodelapp 静态文件路由
|
||||
location /aimodelapp/ {
|
||||
alias /usr/share/nginx/html/aimodelapp/;
|
||||
try_files $uri $uri/ =404;
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
}
|
||||
|
||||
# toolbox 静态文件路由
|
||||
location /toolbox/ {
|
||||
alias /usr/share/nginx/html/toolbox/;
|
||||
try_files $uri $uri/ =404;
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
}
|
||||
|
||||
# 静态资源缓存
|
||||
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# React Router 支持 - 所有其他请求返回 index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
|
||||
# 健康检查
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
26
docker/entrypoint.sh
Normal file
26
docker/entrypoint.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "🚀 启动 InfoGenie 服务..."
|
||||
|
||||
# 创建必要的目录
|
||||
mkdir -p /app/data/logs
|
||||
|
||||
# 检查环境变量
|
||||
if [ -z "$MONGO_URI" ]; then
|
||||
echo "⚠️ 警告: MONGO_URI 未设置"
|
||||
fi
|
||||
|
||||
if [ -z "$MAIL_USERNAME" ]; then
|
||||
echo "⚠️ 警告: MAIL_USERNAME 未设置"
|
||||
fi
|
||||
|
||||
echo "✅ 环境变量检查完成"
|
||||
|
||||
# 测试 Nginx 配置
|
||||
echo "🔍 检查 Nginx 配置..."
|
||||
nginx -t
|
||||
|
||||
# 启动 Supervisor
|
||||
echo "🎯 启动服务进程..."
|
||||
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||
41
docker/nginx.conf
Normal file
41
docker/nginx.conf
Normal file
@@ -0,0 +1,41 @@
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
use epoll;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# 日志格式
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /app/data/logs/nginx_access.log main;
|
||||
error_log /app/data/logs/nginx_error.log warn;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
client_max_body_size 20M;
|
||||
|
||||
# Gzip 压缩
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css text/xml text/javascript
|
||||
application/json application/javascript application/xml+rss
|
||||
application/rss+xml font/truetype font/opentype
|
||||
application/vnd.ms-fontobject image/svg+xml;
|
||||
|
||||
# 包含站点配置
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
24
docker/supervisord.conf
Normal file
24
docker/supervisord.conf
Normal file
@@ -0,0 +1,24 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
user=root
|
||||
logfile=/app/data/logs/supervisord.log
|
||||
pidfile=/var/run/supervisord.pid
|
||||
|
||||
[program:gunicorn]
|
||||
directory=/app/backend
|
||||
command=gunicorn -w 4 -b 127.0.0.1:5002 --timeout 300 --access-logfile /app/data/logs/gunicorn_access.log --error-logfile /app/data/logs/gunicorn_error.log "app:create_app()"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startretries=3
|
||||
stderr_logfile=/app/data/logs/gunicorn_err.log
|
||||
stdout_logfile=/app/data/logs/gunicorn_out.log
|
||||
priority=1
|
||||
|
||||
[program:nginx]
|
||||
command=/usr/sbin/nginx -g "daemon off;"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startretries=3
|
||||
stderr_logfile=/app/data/logs/nginx_err.log
|
||||
stdout_logfile=/app/data/logs/nginx_out.log
|
||||
priority=2
|
||||
Reference in New Issue
Block a user