更新dockerfile

This commit is contained in:
2026-03-24 22:53:03 +08:00
parent d09a0487ae
commit a2c835049f
7 changed files with 141 additions and 23 deletions

30
docker/entrypoint.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/bin/sh
set -e
# 启动 Dart 后端 (内部端口 8081)
echo "Starting Dart backend on port 8081..."
export PORT=8081
/app/bin/server &
BACKEND_PID=$!
# 等待后端启动
sleep 2
# 启动前端 (Node.js SSR, 端口 8080)
echo "Starting frontend on port 8080..."
export PORT=8080
export HOST=0.0.0.0
export BACKEND_URL=http://127.0.0.1:8081
cd /app/web/build
node index.js &
FRONTEND_PID=$!
# 捕获退出信号,优雅关闭两个服务
trap "echo 'Shutting down...'; kill $BACKEND_PID $FRONTEND_PID 2>/dev/null; exit 0" SIGTERM SIGINT
# 等待任意进程退出
wait -n $BACKEND_PID $FRONTEND_PID
# 如果有一个进程退出,杀死另一个
kill $BACKEND_PID $FRONTEND_PID 2>/dev/null || true
exit 1