b7073d9c5b
- Update .env.example with production-ready environment variables - Add frontend Aliyun deployment configuration with nginx gateway - Refactor docker-compose.server.yml for external services - Add comprehensive deployment guide (docs/DEPLOYMENT.md) - Enhance troubleshooting documentation with Git Bash path issues - Add deployment scripts (build-frontend.sh, deploy-frontend.sh) - Add deploy directory with docker-compose and nginx config - Update .gitignore to exclude temporary directories Co-Authored-By: Claude <noreply@anthropic.com>
36 lines
1.2 KiB
Bash
36 lines
1.2 KiB
Bash
#!/bin/bash
|
|
# 前端构建脚本 - 用于生产部署
|
|
# 解决 Git Bash 路径转换问题
|
|
|
|
set -e
|
|
|
|
cd "$(dirname "$0")/frontend"
|
|
|
|
echo "Building Next.js frontend..."
|
|
|
|
# 使用 MSYS_NO_PATHCONV=1 防止 Git Bash 将 /api/v1 转换为 Windows 路径
|
|
# NEXT_PUBLIC_API_BASE_URL: 浏览器端 API 请求路径(相对路径)
|
|
# BACKEND_BASE_URL: 服务器端 rewrites 目标地址
|
|
|
|
export MSYS_NO_PATHCONV=1
|
|
export NEXT_PUBLIC_API_BASE_URL="/api/v1"
|
|
export BACKEND_BASE_URL="http://10.20.0.11:18083"
|
|
|
|
npm run build
|
|
|
|
echo "Copying static assets to standalone..."
|
|
rm -rf .next/standalone/.next/static
|
|
cp -r .next/static .next/standalone/.next/
|
|
|
|
echo "Creating deployment package..."
|
|
tar -czf ../deploy/frontend-standalone.tar.gz -C .next/standalone .
|
|
|
|
echo "Build complete! Package: deploy/frontend-standalone.tar.gz"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. scp deploy/frontend-standalone.tar.gz root@47.94.178.212:/tmp/"
|
|
echo " 2. ssh root@47.94.178.212"
|
|
echo " 3. cd /opt/apps/ai-contract-web/current/app"
|
|
echo " 4. rm -rf .next server.js node_modules public"
|
|
echo " 5. tar -xzf /tmp/frontend-standalone.tar.gz"
|
|
echo " 6. cd /opt/apps/ai-contract-web/current && docker compose down && docker compose up -d --build" |