Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/images_sync.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions cmd/conf.yaml.default
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
### 复制该文件并命名为 conf.yaml,并填充以下自定义配置

# 阿里云个人镜像仓库地址
registry: crpi-xxx.cn-xxx.personal.cr.aliyuncs.com
# 阿里云个人镜像仓库命名空间名称
namespace: xxx
# 所在项目的git仓库本地路径,这里配置错误会导致git push 命令提示仓库不存在
images_dir: "E:\Git\docker_images_sync"
# 单个镜像拉取最大尝试次数,默认为60
registry: crpi-s67w1v25xu5dvvj8.cn-heyuan.personal.cr.aliyuncs.com
namespace: faiz_docker_image_sync
images_dir: "/Users/lyydsheep/workspace/Go/projects/images_sync"
max_retries: 60
# 拉取镜像尝试间隔(秒),默认为1
retry_delay: 1
# 将镜像tag提交后等待多久开始尝试拉取镜像(秒),默认为20
first_delay: 20
8 changes: 8 additions & 0 deletions cmd/docker-compose.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# docker-compose.test.yaml
services:
web:
image: nginx:1.25
db:
image: postgres:15-alpine
cache:
image:
37 changes: 37 additions & 0 deletions cmd/docker_compose_pull
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
docker_compose_pull() {
# Find all matching docker-compose files
compose_files=$(find . -name 'docker-compose*.yaml' -type f 2>/dev/null)

[ -z "$compose_files" ] && {
echo "Error: No docker-compose*.yaml files found"
return 1
}

# Store all image names
declare -a all_images

for file in $compose_files; do
echo "Scanning file: $file"
# Extract all image fields using yq
while IFS= read -r image; do
[ -n "$image" ] && all_images+=("$image")
done < <(yq eval '.services[].image' "$file" | grep -v 'null' | sort -u)
done

[ ${#all_images[@]} -eq 0 ] && {
echo "Warning: No valid image names detected"
return 0
}

# Execute image pulling by docker_pull
echo "Starting image pull..."
for img in "${all_images[@]}"; do
echo "Pulling: $img"
docker_pull "$img"
done
echo "Operation completed!"
}

# Call the function
docker_compose_pull
2 changes: 1 addition & 1 deletion images.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@

golang:1.18
2 changes: 1 addition & 1 deletion sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ failed_images=""
while IFS= read -r image; do
# 拉取镜像
set +e
docker pull "$image"
docker pull --platform linux/arm64 "$image"
pull_status=$?
if [ $pull_status -ne 0 ]; then
echo "Error: Failed to pull image $image, continuing..."
Expand Down