jxdn123 commited on
Commit
d8268b1
·
verified ·
1 Parent(s): 52f37c8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -6
Dockerfile CHANGED
@@ -16,13 +16,16 @@ RUN mkdir -p /var/cache/nginx/client_temp \
16
  /var/log/nginx \
17
  /app/cache
18
 
19
- # 创建 nginx 配置文件 - 指向正确的前端目录
20
- RUN cat > /etc/nginx/conf.d/default.conf <<'EOF'
 
 
 
21
  server {
22
- listen 7860;
23
  server_name _;
24
 
25
- # 前端静态文件 - 正确的路径
26
  root /app/frontend/dist;
27
  index index.html;
28
 
@@ -49,11 +52,27 @@ EOF
49
  RUN sed -i 's/^user\s/#user /g' /etc/nginx/nginx.conf && \
50
  sed -i 's|pid\s*/var/run/nginx.pid;|pid /tmp/nginx.pid;|g' /etc/nginx/nginx.conf
51
 
 
 
 
 
 
 
52
  # 创建启动脚本
53
  RUN cat > /start.sh <<'EOF'
54
  #!/bin/sh
55
  set -e
56
 
 
 
 
 
 
 
 
 
 
 
57
  echo "Starting PanSou backend service..."
58
  # 启动后端 API 服务(后台运行)
59
  cd /app && ./pansou &
@@ -66,11 +85,15 @@ sleep 3
66
  if ! curl -s http://localhost:8888/api/health > /dev/null 2>&1; then
67
  echo "Warning: Backend service may not be running properly"
68
  else
69
- echo "Backend service started successfully"
70
  fi
71
 
 
 
 
 
72
  echo "Starting Nginx on port 7860..."
73
- echo "Frontend files location: /app/frontend/dist"
74
  # 启动 nginx(前台运行)
75
  exec nginx -g "daemon off;"
76
  EOF
 
16
  /var/log/nginx \
17
  /app/cache
18
 
19
+ # 删除所有默认的 nginx 配置
20
+ RUN rm -f /etc/nginx/conf.d/*.conf /etc/nginx/sites-enabled/* /etc/nginx/sites-available/* 2>/dev/null || true
21
+
22
+ # 创建全新的 nginx 配置文件
23
+ RUN cat > /etc/nginx/conf.d/pansou.conf <<'EOF'
24
  server {
25
+ listen 7860 default_server;
26
  server_name _;
27
 
28
+ # 前端静态文件
29
  root /app/frontend/dist;
30
  index index.html;
31
 
 
52
  RUN sed -i 's/^user\s/#user /g' /etc/nginx/nginx.conf && \
53
  sed -i 's|pid\s*/var/run/nginx.pid;|pid /tmp/nginx.pid;|g' /etc/nginx/nginx.conf
54
 
55
+ # 验证配置内容
56
+ RUN echo "=== Nginx config check ===" && \
57
+ cat /etc/nginx/conf.d/pansou.conf && \
58
+ echo "=== End of config ===" && \
59
+ ls -la /etc/nginx/conf.d/
60
+
61
  # 创建启动脚本
62
  RUN cat > /start.sh <<'EOF'
63
  #!/bin/sh
64
  set -e
65
 
66
+ echo "=== Starting PanSou Service ==="
67
+
68
+ # 显示前端文件
69
+ echo "Checking frontend files..."
70
+ ls -la /app/frontend/dist/ | head -10
71
+
72
+ # 显示 nginx 配置
73
+ echo "Nginx configuration:"
74
+ cat /etc/nginx/conf.d/pansou.conf
75
+
76
  echo "Starting PanSou backend service..."
77
  # 启动后端 API 服务(后台运行)
78
  cd /app && ./pansou &
 
85
  if ! curl -s http://localhost:8888/api/health > /dev/null 2>&1; then
86
  echo "Warning: Backend service may not be running properly"
87
  else
88
+ echo "Backend service started successfully on port 8888"
89
  fi
90
 
91
+ # 测试 nginx 配置
92
+ echo "Testing nginx configuration..."
93
+ nginx -t
94
+
95
  echo "Starting Nginx on port 7860..."
96
+ echo "Frontend root: /app/frontend/dist"
97
  # 启动 nginx(前台运行)
98
  exec nginx -g "daemon off;"
99
  EOF