Skip to content

Commit

Permalink
支持k8s.gcr.io等
Browse files Browse the repository at this point in the history
  • Loading branch information
tech-shrimp committed Jun 12, 2024
1 parent 654e410 commit 63a6450
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}_"
Expand All @@ -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}')
Expand All @@ -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}')
Expand Down
4 changes: 3 additions & 1 deletion images.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 63a6450

Please sign in to comment.