Files
my-blog/deploy.sh
T
admin ea09c73f2b
Build and Deploy Blog / deploy (push) Successful in 24s
chore: 部署脚本增加自动清理旧 blog-mysql 容器逻辑
2026-10-22 15:42:38 +08:00

33 lines
1003 B
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
set -e
echo "=========================================="
echo "🚀 [CI/CD] 开始构建并部署旺总的全栈个人博客..."
echo "=========================================="
# 1. 拉取最新代码
if [ -d ".git" ]; then
echo "📥 [Git] 拉取远程最新代码..."
git pull origin main || true
fi
# 2. 清理旧的独立 blog-mysql 容器(改用 1Panel 现有 MySQL)
docker stop blog-mysql 2>/dev/null || true
docker rm blog-mysql 2>/dev/null || true
# 3. 重新编译后端与前端容器
echo "🐳 [Docker] 重新构建并运行全栈容器..."
docker compose down
docker compose up -d --build
# 4. 检查服务健康状态
echo "⏳ [HealthCheck] 等待服务启动..."
sleep 3
docker ps --filter "name=blog-"
echo "=========================================="
echo "🎉 部署完成!"
echo "🌐 博客前端: http://<你的服务器IP>:8088"
echo "🔌 后端 API: http://<你的服务器IP>:8089/api/posts"
echo "=========================================="