From 7fcedf7e08a1f2b117d23342d6873583832161e5 Mon Sep 17 00:00:00 2001 From: Developer Date: Tue, 2 Dec 2025 08:24:20 -0800 Subject: [PATCH] =?UTF-8?q?feat(admin-web):=20=E6=B7=BB=E5=8A=A0=20Docker?= =?UTF-8?q?=20=E7=AE=A1=E7=90=86=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- frontend/admin-web/scripts/build.sh | 7 +++++++ frontend/admin-web/scripts/clean.sh | 8 ++++++++ frontend/admin-web/scripts/deploy.sh | 15 +++++++++++++++ frontend/admin-web/scripts/health.sh | 12 ++++++++++++ frontend/admin-web/scripts/logs.sh | 5 +++++ frontend/admin-web/scripts/restart.sh | 7 +++++++ frontend/admin-web/scripts/start.sh | 8 ++++++++ frontend/admin-web/scripts/status.sh | 5 +++++ frontend/admin-web/scripts/stop.sh | 7 +++++++ 9 files changed, 74 insertions(+) create mode 100644 frontend/admin-web/scripts/build.sh create mode 100644 frontend/admin-web/scripts/clean.sh create mode 100644 frontend/admin-web/scripts/deploy.sh create mode 100644 frontend/admin-web/scripts/health.sh create mode 100644 frontend/admin-web/scripts/logs.sh create mode 100644 frontend/admin-web/scripts/restart.sh create mode 100644 frontend/admin-web/scripts/start.sh create mode 100644 frontend/admin-web/scripts/status.sh create mode 100644 frontend/admin-web/scripts/stop.sh diff --git a/frontend/admin-web/scripts/build.sh b/frontend/admin-web/scripts/build.sh new file mode 100644 index 00000000..a87fe94c --- /dev/null +++ b/frontend/admin-web/scripts/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# 构建 Docker 镜像 +set -e +cd "$(dirname "$0")/.." +echo "🔨 构建 Docker 镜像..." +docker compose build --no-cache +echo "✅ 构建完成" diff --git a/frontend/admin-web/scripts/clean.sh b/frontend/admin-web/scripts/clean.sh new file mode 100644 index 00000000..1d78ae38 --- /dev/null +++ b/frontend/admin-web/scripts/clean.sh @@ -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 "✅ 清理完成" diff --git a/frontend/admin-web/scripts/deploy.sh b/frontend/admin-web/scripts/deploy.sh new file mode 100644 index 00000000..1366b2b7 --- /dev/null +++ b/frontend/admin-web/scripts/deploy.sh @@ -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" diff --git a/frontend/admin-web/scripts/health.sh b/frontend/admin-web/scripts/health.sh new file mode 100644 index 00000000..cf011376 --- /dev/null +++ b/frontend/admin-web/scripts/health.sh @@ -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 diff --git a/frontend/admin-web/scripts/logs.sh b/frontend/admin-web/scripts/logs.sh new file mode 100644 index 00000000..4ff1383a --- /dev/null +++ b/frontend/admin-web/scripts/logs.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# 查看实时日志 +cd "$(dirname "$0")/.." +echo "📋 查看日志 (Ctrl+C 退出)..." +docker compose logs -f diff --git a/frontend/admin-web/scripts/restart.sh b/frontend/admin-web/scripts/restart.sh new file mode 100644 index 00000000..3e8b0558 --- /dev/null +++ b/frontend/admin-web/scripts/restart.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# 重启服务 +set -e +cd "$(dirname "$0")/.." +echo "🔄 重启服务..." +docker compose restart +echo "✅ 服务已重启" diff --git a/frontend/admin-web/scripts/start.sh b/frontend/admin-web/scripts/start.sh new file mode 100644 index 00000000..c585d79d --- /dev/null +++ b/frontend/admin-web/scripts/start.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# 启动服务 +set -e +cd "$(dirname "$0")/.." +echo "🚀 启动服务..." +docker compose up -d +echo "✅ 服务已启动" +echo "📍 访问地址: http://localhost:${PORT:-3000}" diff --git a/frontend/admin-web/scripts/status.sh b/frontend/admin-web/scripts/status.sh new file mode 100644 index 00000000..a36f8e36 --- /dev/null +++ b/frontend/admin-web/scripts/status.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# 查看服务状态 +cd "$(dirname "$0")/.." +echo "📊 服务状态:" +docker compose ps diff --git a/frontend/admin-web/scripts/stop.sh b/frontend/admin-web/scripts/stop.sh new file mode 100644 index 00000000..d10c1981 --- /dev/null +++ b/frontend/admin-web/scripts/stop.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# 停止服务 +set -e +cd "$(dirname "$0")/.." +echo "🛑 停止服务..." +docker compose down +echo "✅ 服务已停止"