perf(部署脚本): 优化docker部署流程,避免重复构建镜像
检查镜像是否已存在,若存在则直接使用,否则才构建新镜像
This commit is contained in:
parent
455859dab6
commit
60faf18220
|
|
@ -24,7 +24,12 @@ fi
|
||||||
if [ -z "$ENV_FILE" ]; then
|
if [ -z "$ENV_FILE" ]; then
|
||||||
echo "未使用 env 文件,配置仅通过 server/config.$ENV_NAME.yaml 加载" >&2
|
echo "未使用 env 文件,配置仅通过 server/config.$ENV_NAME.yaml 加载" >&2
|
||||||
fi
|
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
|
mkdir -p log storage/export
|
||||||
CID_NAME="marketing-data-$ENV_NAME"
|
CID_NAME="marketing-data-$ENV_NAME"
|
||||||
RUNNING=$(docker inspect -f '{{.State.Running}}' "$CID_NAME" 2>/dev/null || echo false)
|
RUNNING=$(docker inspect -f '{{.State.Running}}' "$CID_NAME" 2>/dev/null || echo false)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue