feat(admin-web): 添加 Docker 管理脚本

- build.sh: 构建 Docker 镜像
- start.sh: 启动服务
- stop.sh: 停止服务
- restart.sh: 重启服务
- logs.sh: 查看实时日志
- status.sh: 查看服务状态
- health.sh: 健康检查
- clean.sh: 清理容器和镜像
- deploy.sh: 一键部署 (构建+启动)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Developer 2025-12-02 08:24:20 -08:00
parent 40e0caaad5
commit 7fcedf7e08
9 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,7 @@
#!/bin/bash
# 构建 Docker 镜像
set -e
cd "$(dirname "$0")/.."
echo "🔨 构建 Docker 镜像..."
docker compose build --no-cache
echo "✅ 构建完成"

View File

@ -0,0 +1,8 @@
#!/bin/bash
# 清理容器、镜像和卷
set -e
cd "$(dirname "$0")/.."
echo "🧹 清理容器和镜像..."
docker compose down --rmi local --volumes --remove-orphans
docker image prune -f
echo "✅ 清理完成"

View File

@ -0,0 +1,15 @@
#!/bin/bash
# 一键部署 (构建 + 启动)
set -e
cd "$(dirname "$0")/.."
echo "🚀 开始一键部署..."
echo ""
echo "🔨 步骤 1/2: 构建镜像..."
docker compose build --no-cache
echo ""
echo "🚀 步骤 2/2: 启动服务..."
docker compose up -d
echo ""
echo "✅ 部署完成!"
echo "📍 访问地址: http://localhost:${PORT:-3000}"
echo "📋 查看日志: ./scripts/logs.sh"

View File

@ -0,0 +1,12 @@
#!/bin/bash
# 健康检查
cd "$(dirname "$0")/.."
echo "🏥 健康检查..."
response=$(curl -s http://localhost:${PORT:-3000}/api/health)
if [ $? -eq 0 ]; then
echo "✅ 服务健康"
echo "$response" | python3 -m json.tool 2>/dev/null || echo "$response"
else
echo "❌ 服务不可用"
exit 1
fi

View File

@ -0,0 +1,5 @@
#!/bin/bash
# 查看实时日志
cd "$(dirname "$0")/.."
echo "📋 查看日志 (Ctrl+C 退出)..."
docker compose logs -f

View File

@ -0,0 +1,7 @@
#!/bin/bash
# 重启服务
set -e
cd "$(dirname "$0")/.."
echo "🔄 重启服务..."
docker compose restart
echo "✅ 服务已重启"

View File

@ -0,0 +1,8 @@
#!/bin/bash
# 启动服务
set -e
cd "$(dirname "$0")/.."
echo "🚀 启动服务..."
docker compose up -d
echo "✅ 服务已启动"
echo "📍 访问地址: http://localhost:${PORT:-3000}"

View File

@ -0,0 +1,5 @@
#!/bin/bash
# 查看服务状态
cd "$(dirname "$0")/.."
echo "📊 服务状态:"
docker compose ps

View File

@ -0,0 +1,7 @@
#!/bin/bash
# 停止服务
set -e
cd "$(dirname "$0")/.."
echo "🛑 停止服务..."
docker compose down
echo "✅ 服务已停止"