修改了部署文件
parent
126167715e
commit
c08602ac56
|
|
@ -72,20 +72,35 @@ services:
|
|||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
env_file:
|
||||
- ./backend/.env
|
||||
environment:
|
||||
# Python环境
|
||||
TZ: Asia/Shanghai
|
||||
PYTHONPATH: /app
|
||||
PYTHONUNBUFFERED: 1
|
||||
# 强制使用容器内部服务名,覆盖本地.env配置
|
||||
|
||||
# 数据库配置
|
||||
DB_HOST: mysql
|
||||
DB_PORT: 3306
|
||||
DB_USER: ${MYSQL_USER:-imeeting}
|
||||
DB_PASSWORD: ${MYSQL_PASSWORD:-Unis@123}
|
||||
DB_NAME: ${MYSQL_DATABASE:-imeeting}
|
||||
|
||||
# Redis配置
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: 6379
|
||||
REDIS_DB: ${REDIS_DB:-0}
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-Unis@123}
|
||||
|
||||
# API配置
|
||||
API_HOST: 0.0.0.0
|
||||
API_PORT: 8000
|
||||
BASE_URL: ${BASE_URL:-http://localhost}
|
||||
|
||||
# LLM配置
|
||||
QWEN_API_KEY: ${QWEN_API_KEY}
|
||||
# 后端不直接暴露端口,通过nginx代理访问
|
||||
# ports:
|
||||
# - "${BACKEND_PORT:-8000}:8000"
|
||||
ports:
|
||||
- "${BACKEND_PORT:-8000}:8000"
|
||||
volumes:
|
||||
- ./data/uploads:/app/uploads
|
||||
- ./data/logs/backend:/app/logs
|
||||
|
|
@ -111,8 +126,8 @@ services:
|
|||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
# 前端不直接暴露端口,通过nginx代理访问
|
||||
# ports:
|
||||
# - "${FRONTEND_PORT:-3001}:80"
|
||||
ports:
|
||||
- "${HTTP_PORT:-80}:80"
|
||||
volumes:
|
||||
- ./data/logs/frontend:/var/log/nginx
|
||||
healthcheck:
|
||||
|
|
|
|||
124
start.sh
124
start.sh
|
|
@ -82,7 +82,6 @@ create_directories() {
|
|||
|
||||
# MySQL和Nginx配置目录
|
||||
mkdir -p mysql/conf.d
|
||||
mkdir -p nginx/conf.d
|
||||
|
||||
# 数据持久化目录
|
||||
mkdir -p data/mysql
|
||||
|
|
@ -90,7 +89,6 @@ create_directories() {
|
|||
mkdir -p data/uploads
|
||||
mkdir -p data/logs/backend
|
||||
mkdir -p data/logs/frontend
|
||||
mkdir -p data/logs/nginx
|
||||
|
||||
# 后端配置和备份目录
|
||||
mkdir -p backend/config
|
||||
|
|
@ -99,124 +97,6 @@ create_directories() {
|
|||
print_success "目录创建完成"
|
||||
}
|
||||
|
||||
# 生成Nginx配置
|
||||
generate_nginx_config() {
|
||||
print_info "检查Nginx配置..."
|
||||
|
||||
if [ ! -f nginx/nginx.conf ]; then
|
||||
print_warning "nginx/nginx.conf 不存在,正在生成默认配置..."
|
||||
cat > nginx/nginx.conf <<EOF
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
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 /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
EOF
|
||||
print_success "nginx/nginx.conf 已生成"
|
||||
fi
|
||||
|
||||
if [ ! -f nginx/conf.d/default.conf ]; then
|
||||
print_warning "nginx/conf.d/default.conf 不存在,正在生成默认站点配置..."
|
||||
cat > nginx/conf.d/default.conf <<EOF
|
||||
upstream frontend_server {
|
||||
server frontend:80;
|
||||
}
|
||||
|
||||
upstream backend_server {
|
||||
server backend:8000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
# 增加上传文件大小限制
|
||||
client_max_body_size 100M;
|
||||
|
||||
# 后端API直连
|
||||
location /api/ {
|
||||
proxy_pass http://backend_server;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
|
||||
# 增加API超时时间
|
||||
proxy_read_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
}
|
||||
|
||||
# 上传文件直连
|
||||
location /uploads/ {
|
||||
proxy_pass http://backend_server;
|
||||
proxy_http_version 1.1;
|
||||
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;
|
||||
|
||||
# 静态资源缓存配置
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, no-transform";
|
||||
}
|
||||
|
||||
# 前端代理 (其他请求)
|
||||
location / {
|
||||
proxy_pass http://frontend_server;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade \$http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host \$host;
|
||||
proxy_cache_bypass \$http_upgrade;
|
||||
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;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
print_success "nginx/conf.d/default.conf 已生成"
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查并创建后端环境变量文件
|
||||
check_backend_env() {
|
||||
print_info "检查后端环境变量配置..."
|
||||
|
||||
if [ ! -f backend/.env ]; then
|
||||
print_warning "backend/.env 文件不存在,从模板创建..."
|
||||
|
||||
if [ -f backend/.env.example ]; then
|
||||
cp backend/.env.example backend/.env
|
||||
print_success "已创建 backend/.env"
|
||||
else
|
||||
print_warning "backend/.env.example 不存在,跳过"
|
||||
fi
|
||||
else
|
||||
print_success "后端环境变量文件已存在"
|
||||
fi
|
||||
}
|
||||
|
||||
# 启动服务
|
||||
start_services() {
|
||||
print_info "启动 Docker 服务..."
|
||||
|
|
@ -248,7 +128,7 @@ wait_for_health() {
|
|||
fi
|
||||
|
||||
local healthy_count=$($COMPOSE_CMD ps --format json 2>/dev/null | grep -c '"Health":"healthy"' || echo "0")
|
||||
local total_count=5 # mysql, redis, backend, frontend, nginx
|
||||
local total_count=4 # mysql, redis, backend, frontend
|
||||
|
||||
if [ "$healthy_count" -eq "$total_count" ]; then
|
||||
print_success "所有服务已就绪"
|
||||
|
|
@ -316,9 +196,7 @@ main() {
|
|||
|
||||
check_dependencies
|
||||
check_env_file
|
||||
check_backend_env
|
||||
create_directories
|
||||
generate_nginx_config
|
||||
start_services
|
||||
|
||||
echo ""
|
||||
|
|
|
|||
Loading…
Reference in New Issue