From 63a6450320fda0a54f1e1bee6049289d3018459f Mon Sep 17 00:00:00 2001 From: tech-shrimp Date: Wed, 12 Jun 2024 12:00:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81k8s.gcr.io=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker.yaml | 18 ++++++++++++++---- images.txt | 4 +++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index c2460d8434..5a2c0fafc1 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -31,15 +31,20 @@ jobs: declare -A duplicate_images declare -A temp_map while IFS= read -r line; do + # 忽略空行与注释 [[ -z "$line" ]] && continue + if echo "$line" | grep -q '^\s*#'; then + continue + fi + # 获取镜像的完整名称,例如kasmweb/nginx:1.25.3(命名空间/镜像名:版本号) image=$(echo "$line" | awk '{print $NF}') echo "image $image" # 获取镜像名:版本号 例如nginx:1.25.3 image_name_tag=$(echo "$image" | awk -F'/' '{print $NF}') echo "image_name_tag $image_name_tag" - # 获取命名空间 - name_space=$(echo "$image" | awk -F'/' '{if (NF>1) print $1}'| awk '{print $1}') + # 获取命名空间 例如kasmweb, 这里有种特殊情况 docker.io/nginx,把docker.io当成命名空间,也OK + name_space=$(echo "$image" | awk -F'/' '{if (NF==3) print $2; else if (NF==2) print $1; else print ""}') echo "name_space: $name_space" # 这里不要是空值影响判断 name_space="${name_space}_" @@ -61,7 +66,12 @@ jobs: while IFS= read -r line; do + # 忽略空行与注释 [[ -z "$line" ]] && continue + if echo "$line" | grep -q '^\s*#'; then + continue + fi + echo "docker pull $line" docker pull $line platform=$(echo "$line" | awk -F'--platform[ =]' '{if (NF>1) print $2}' | awk '{print $1}') @@ -77,8 +87,8 @@ jobs: image=$(echo "$line" | awk '{print $NF}') # 获取 镜像名:版本号 例如nginx:1.25.3 image_name_tag=$(echo "$image" | awk -F'/' '{print $NF}') - # 获取命名空间 例如kasmweb - name_space=$(echo "$image" | awk -F'/' '{if (NF>1) print $1}'| awk '{print $1}') + # 获取命名空间 例如kasmweb 这里有种特殊情况 docker.io/nginx,把docker.io当成命名空间,也OK + name_space=$(echo "$image" | awk -F'/' '{if (NF==3) print $2; else if (NF==2) print $1; else print ""}') # 获取镜像名例 例如nginx image_name=$(echo "$image_name_tag" | awk -F':' '{print $1}') diff --git a/images.txt b/images.txt index 45f4478c3b..8b2e8168c0 100644 --- a/images.txt +++ b/images.txt @@ -1,4 +1,6 @@ nginx -kasmweb/nginx:1.25.3 +#支持私库 +k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.0.0 xhofe/alist:latest +#支持指定架构 --platform=linux/arm64 xiaoyaliu/alist