AIGC/aigc-ui/deploy.sh
2026-02-27 14:37:19 +08:00

76 lines
1.7 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# AIGC 前端部署脚本
# 使用方法: ./deploy.sh
set -e
echo "======================================"
echo "AIGC 前端项目生产环境部署"
echo "======================================"
echo ""
# 颜色输出
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# 检查 Node.js 是否安装
if ! command -v node &> /dev/null; then
echo -e "${RED}错误: 未检测到 Node.js请先安装 Node.js${NC}"
exit 1
fi
echo -e "${GREEN}Node.js 版本: $(node -v)${NC}"
echo -e "${GREEN}npm 版本: $(npm -v)${NC}"
echo ""
# 1. 安装依赖
echo -e "${YELLOW}[1/4] 安装依赖...${NC}"
npm install
echo -e "${GREEN}✓ 依赖安装完成${NC}"
echo ""
# 2. 构建生产版本
echo -e "${YELLOW}[2/4] 构建生产版本...${NC}"
npm run build
echo -e "${GREEN}✓ 构建完成${NC}"
echo ""
# 3. 检查构建产物
if [ ! -d "dist" ]; then
echo -e "${RED}错误: dist 目录不存在,构建失败${NC}"
exit 1
fi
echo -e "${YELLOW}[3/4] 构建产物信息:${NC}"
du -sh dist
echo ""
# 4. 打包构建产物
echo -e "${YELLOW}[4/4] 打包构建产物...${NC}"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
PACKAGE_NAME="aigc-ui-${TIMESTAMP}.tar.gz"
tar -czf ${PACKAGE_NAME} dist/
echo -e "${GREEN}✓ 打包完成: ${PACKAGE_NAME}${NC}"
echo ""
echo "======================================"
echo -e "${GREEN}部署准备完成!${NC}"
echo "======================================"
echo ""
echo "下一步操作:"
echo "1. 上传到服务器:"
echo " scp ${PACKAGE_NAME} user@server:/path/to/deploy/"
echo ""
echo "2. 在服务器上解压:"
echo " tar -xzf ${PACKAGE_NAME}"
echo ""
echo "3. 配置 Nginx 指向 dist 目录"
echo ""
echo "或者直接使用 deploy-to-server.sh 脚本自动部署"
echo ""