fix: include frontend dist assets in repo, fix deploy.sh syntax
- Remove .gitignore exclusion for dist/assets/ and frontend/dist/ - Fix deploy.sh: add missing quote on echo line - Fix deploy.sh: correct ADMIN_PASSWORD=*** syntax - Make deploy.sh auto-detect go/npm availability
This commit is contained in:
@@ -6,8 +6,6 @@ backend/data/
|
|||||||
|
|
||||||
# 编译产物
|
# 编译产物
|
||||||
backend/autossl
|
backend/autossl
|
||||||
backend/dist/assets/
|
|
||||||
frontend/dist/
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
|
|||||||
+95
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
@@ -1,34 +1,53 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "=== Auto-SSL 一键部署脚本 ===
|
DEPLOY_DIR="$PWD"
|
||||||
|
|
||||||
|
echo "=== Auto-SSL 一键部署脚本 ==="
|
||||||
|
|
||||||
# 1. 拉取最新代码
|
# 1. 拉取最新代码
|
||||||
echo "1. 拉取最新代码..."
|
echo "1. 拉取最新代码..."
|
||||||
git pull origin master 2>/dev/null || git pull origin 0.01 2>/dev/null || echo " (跳过git拉取)"
|
git pull origin master 2>/dev/null || git pull origin 0.0.2 2>/dev/null || echo " (跳过git拉取)"
|
||||||
|
|
||||||
|
# 检查是否有构建环境
|
||||||
|
HAS_GO=$(command -v go &>/dev/null && echo "yes" || echo "no")
|
||||||
|
HAS_NPM=$(command -v npm &>/dev/null && echo "yes" || echo "no")
|
||||||
|
|
||||||
# 2. 编译后端
|
# 2. 编译后端
|
||||||
|
if [ "$HAS_GO" = "yes" ]; then
|
||||||
echo "2. 编译Go后端..."
|
echo "2. 编译Go后端..."
|
||||||
cd backend
|
cd backend
|
||||||
go build -o autossl .
|
go build -o autossl .
|
||||||
cd ..
|
cd "$DEPLOY_DIR"
|
||||||
|
else
|
||||||
|
echo "2. 跳过Go编译(未安装go),使用预编译二进制"
|
||||||
|
fi
|
||||||
|
|
||||||
# 3. 编译前端
|
# 3. 编译前端
|
||||||
|
if [ "$HAS_NPM" = "yes" ]; then
|
||||||
echo "3. 编译Vue前端..."
|
echo "3. 编译Vue前端..."
|
||||||
cd frontend
|
cd frontend
|
||||||
npm install --include=dev
|
npm install --include=dev
|
||||||
npm run build
|
npm run build
|
||||||
cd ..
|
cd "$DEPLOY_DIR"
|
||||||
|
else
|
||||||
|
echo "3. 跳过前端编译(未安装npm),使用预构建dist"
|
||||||
|
fi
|
||||||
|
|
||||||
# 4. 部署前端资源...
|
# 4. 部署前端资源
|
||||||
echo "4. 部署前端资源..."
|
echo "4. 部署前端资源..."
|
||||||
|
if [ -d "frontend/dist" ] && [ -n "$(ls -A frontend/dist 2>/dev/null)" ]; then
|
||||||
rm -rf backend/dist
|
rm -rf backend/dist
|
||||||
mkdir -p backend/dist
|
mkdir -p backend/dist
|
||||||
cp -rf frontend/dist/* backend/dist/
|
cp -rf frontend/dist/* backend/dist/
|
||||||
|
echo " 前端资源已部署"
|
||||||
|
else
|
||||||
|
echo " frontend/dist 为空或不存,跳过"
|
||||||
|
fi
|
||||||
|
|
||||||
# 5. 创建systemd服务
|
# 5. 安装systemd服务
|
||||||
echo "5. 安装systemd服务..."
|
echo "5. 安装systemd服务..."
|
||||||
cat > /tmp/autossl.service << EOF
|
cat > /tmp/autossl.service << EOSERVICE
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Auto-SSL 证书管理服务
|
Description=Auto-SSL 证书管理服务
|
||||||
After=network.target
|
After=network.target
|
||||||
@@ -37,23 +56,23 @@ Wants=network.target
|
|||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=$PWD/backend
|
WorkingDirectory=${DEPLOY_DIR}/backend
|
||||||
Environment="PORT=9090"
|
Environment="PORT=9090"
|
||||||
Environment="ACME_PORT=8082"
|
Environment="ACME_PORT=8082"
|
||||||
Environment="GIN_MODE=release"
|
Environment="GIN_MODE=release"
|
||||||
Environment="ADMIN_USER=admin"
|
Environment="ADMIN_USER=admin"
|
||||||
Environment="ADMIN_PASSWORD=****?
|
Environment="ADMIN_PASSWORD=admin123"
|
||||||
Environment="JWT_SECRET="
|
Environment="JWT_SECRET="
|
||||||
# 飞书机器人通知(可选)
|
# 通知配置可在 Web 界面中设置,无需环境变量
|
||||||
|
# 环境变量会覆盖 Web 界面配置(向后兼容)
|
||||||
# Environment="FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx"
|
# Environment="FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx"
|
||||||
# 邮件通知(可选)
|
|
||||||
# Environment="SMTP_HOST=smtp.example.com"
|
# Environment="SMTP_HOST=smtp.example.com"
|
||||||
# Environment="SMTP_PORT=587"
|
# Environment="SMTP_PORT=587"
|
||||||
# Environment="SMTP_USER=user@example.com"
|
# Environment="SMTP_USER=user@example.com"
|
||||||
# Environment="SMTP_PASSWORD=password"
|
# Environment="SMTP_PASSWORD=password"
|
||||||
# Environment="SMTP_FROM=user@example.com"
|
# Environment="SMTP_FROM=user@example.com"
|
||||||
# Environment="NOTIFY_TO=admin@example.com"
|
# Environment="NOTIFY_TO=admin@example.com"
|
||||||
ExecStart=$PWD/backend/autossl
|
ExecStart=${DEPLOY_DIR}/backend/autossl
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
StandardOutput=journal+console
|
StandardOutput=journal+console
|
||||||
@@ -62,14 +81,14 @@ SyslogIdentifier=autossl
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOSERVICE
|
||||||
sudo cp /tmp/autossl.service /etc/systemd/system/autossl.service
|
cp /tmp/autossl.service /etc/systemd/system/autossl.service
|
||||||
sudo systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
sudo systemctl enable autossl
|
systemctl enable autossl
|
||||||
|
|
||||||
# 6. 重启服务
|
# 6. 重启服务
|
||||||
echo "6. 重启服务..."
|
echo "6. 重启服务..."
|
||||||
sudo systemctl restart autossl
|
systemctl restart autossl
|
||||||
|
|
||||||
# 7. 检查状态
|
# 7. 检查状态
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|||||||
Reference in New Issue
Block a user