test
This commit is contained in:
@@ -117,6 +117,12 @@ check_scripts() {
|
||||
done
|
||||
}
|
||||
|
||||
# 镜像是否存在
|
||||
image_exists() {
|
||||
local image_ref="$1"
|
||||
docker image inspect "$image_ref" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# 构建镜像
|
||||
build_image() {
|
||||
log_info "开始构建Docker镜像..."
|
||||
@@ -183,10 +189,13 @@ deploy_app() {
|
||||
|
||||
log_info "部署应用到: $deploy_dir"
|
||||
|
||||
# 检查镜像
|
||||
if ! docker images | grep -q "${PROJECT_NAME}:${VERSION}"; then
|
||||
log_error "镜像 ${PROJECT_NAME}:${VERSION} 不存在,请先构建: $0 build"
|
||||
exit 1
|
||||
# 检查镜像(若不存在则自动构建一次)
|
||||
if ! image_exists "${PROJECT_NAME}:${VERSION}"; then
|
||||
log_warn "未找到镜像 ${PROJECT_NAME}:${VERSION},尝试自动构建..."
|
||||
build_image || {
|
||||
log_error "自动构建镜像失败,请手动执行: $0 build";
|
||||
exit 1;
|
||||
}
|
||||
fi
|
||||
|
||||
# 创建部署目录
|
||||
|
||||
Reference in New Issue
Block a user