From 60faf18220e218feb2e29cecf1c7bdb7ac1d0947 Mon Sep 17 00:00:00 2001 From: zhouyonggao <1971162852@qq.com> Date: Fri, 28 Nov 2025 17:00:21 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E9=83=A8=E7=BD=B2=E8=84=9A=E6=9C=AC):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96docker=E9=83=A8=E7=BD=B2=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 检查镜像是否已存在,若存在则直接使用,否则才构建新镜像 --- scripts/deploy_docker.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/deploy_docker.sh b/scripts/deploy_docker.sh index 3c998f9..e3b1cd1 100644 --- a/scripts/deploy_docker.sh +++ b/scripts/deploy_docker.sh @@ -24,7 +24,12 @@ fi if [ -z "$ENV_FILE" ]; then echo "未使用 env 文件,配置仅通过 server/config.$ENV_NAME.yaml 加载" >&2 fi -docker build -t "$IMAGE:$TAG" -f Dockerfile . +if docker image inspect "$IMAGE:$TAG" >/dev/null 2>&1; then + echo "使用已有镜像: $IMAGE:$TAG" +else + echo "镜像不存在,开始构建: $IMAGE:$TAG" + docker build -t "$IMAGE:$TAG" -f Dockerfile . +fi mkdir -p log storage/export CID_NAME="marketing-data-$ENV_NAME" RUNNING=$(docker inspect -f '{{.State.Running}}' "$CID_NAME" 2>/dev/null || echo false)