From 0e96c5bcb0f0732e114b05713b619425da5b4d19 Mon Sep 17 00:00:00 2001 From: yuyr Date: Mon, 13 Oct 2025 15:17:33 +0800 Subject: [PATCH] =?UTF-8?q?[#15]=20=E5=A2=9E=E5=8A=A0=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=20--no-cache=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/build_images.sh | 13 +++++++++++++ src/master/scripts/build_images.sh | 9 ++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/build/build_images.sh b/build/build_images.sh index bf712a4..562c964 100755 --- a/build/build_images.sh +++ b/build/build_images.sh @@ -10,6 +10,7 @@ Usage: $0 [OPTIONS] Options: --intranet Use intranet mirror for log/bind builds --master-offline Build master offline image (requires src/master/offline_wheels.tar.gz) + --no-cache Build all images without using Docker layer cache -h, --help Show this help message Examples: @@ -23,6 +24,7 @@ EOF use_intranet=false build_master=true build_master_offline=false +no_cache=false while [[ $# -gt 0 ]]; do case $1 in @@ -39,6 +41,10 @@ while [[ $# -gt 0 ]]; do build_master_offline=true shift ;; + --no-cache) + no_cache=true + shift + ;; -h|--help) show_help exit 0 @@ -65,6 +71,10 @@ cd "$root" load_build_user build_args+=("--build-arg" "ARGUS_BUILD_UID=${ARGUS_BUILD_UID}" "--build-arg" "ARGUS_BUILD_GID=${ARGUS_BUILD_GID}") +if [[ "$no_cache" == true ]]; then + build_args+=("--no-cache") +fi + master_root="$root/src/master" master_offline_tar="$master_root/offline_wheels.tar.gz" master_offline_dir="$master_root/offline_wheels" @@ -159,6 +169,9 @@ if [[ "$build_master" == true ]]; then if [[ "$build_master_offline" == true ]]; then master_args+=("--offline") fi + if [[ "$no_cache" == true ]]; then + master_args+=("--no-cache") + fi if ./scripts/build_images.sh "${master_args[@]}"; then if [[ "$build_master_offline" == true ]]; then images_built+=("argus-master:offline") diff --git a/src/master/scripts/build_images.sh b/src/master/scripts/build_images.sh index ebb8060..914cadb 100755 --- a/src/master/scripts/build_images.sh +++ b/src/master/scripts/build_images.sh @@ -3,12 +3,13 @@ set -euo pipefail usage() { cat >&2 <<'USAGE' -Usage: $0 [--intranet] [--offline] [--tag ] +Usage: $0 [--intranet] [--offline] [--tag ] [--no-cache] Options: --intranet 使用指定的 PyPI 镜像源(默认清华镜像)。 --offline 完全离线构建,依赖 offline_wheels/ 目录中的离线依赖包。 --tag 自定义镜像标签,默认 argus-master:latest。 + --no-cache 不使用 Docker 构建缓存。 USAGE } @@ -19,6 +20,7 @@ IMAGE_TAG="${IMAGE_TAG:-argus-master:latest}" DOCKERFILE="src/master/Dockerfile" BUILD_ARGS=() OFFLINE_MODE=0 +NO_CACHE=0 source "$PROJECT_ROOT/scripts/common/build_user.sh" load_build_user @@ -45,6 +47,11 @@ while [[ "$#" -gt 0 ]]; do IMAGE_TAG="$2" shift 2 ;; + --no-cache) + NO_CACHE=1 + BUILD_ARGS+=("--no-cache") + shift + ;; -h|--help) usage exit 0