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
2 changes: 1 addition & 1 deletion .github/workflows/sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
uses: actions/checkout@v4
- name: login to docker registry
run: |
docker login -u "${{ secrets.DOCKER_USER }}" -p "${{ secrets.DOCKER_PWD }}" "${{ secrets.DOCKER_REGISTRY }}"
docker login -u "${{ secrets.DOCKER_USER }}" -p '${{ secrets.DOCKER_PWD }}' "${{ secrets.DOCKER_REGISTRY }}"
- name: execute sync.sh
run: |
bash "${{ github.workspace }}/sync.sh" "${{ github.workspace }}/images.txt" "${{ secrets.DOCKER_REGISTRY }}" "${{ secrets.DOCKER_NS }}"
Expand Down
32 changes: 31 additions & 1 deletion cmd/docker_pull
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ if [ ! -f "$CONFIG_FILE" ]; then
exit 1
fi

# Get operating system type
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
if [[ "$OS" == "darwin" ]]; then
OS="linux" # Docker Desktop on macOS runs Linux containers
fi

# Get architecture
ARCH=$(uname -m)
case "$ARCH" in
x86_64)
ARCH="amd64"
;;
aarch64|arm64)
ARCH="arm64"
;;
armv7*)
ARCH="arm/v7"
;;
armv6*)
ARCH="arm/v6"
;;
i386|i686)
ARCH="386"
;;
*)
# 保持原样
;;
esac
DOCKER_PLATFORM="$OS/$ARCH"

# Initialize variables
REGISTRY_URL=""
REGISTRY_NS=""
Expand Down Expand Up @@ -83,7 +113,7 @@ popd > /dev/null

# Write images.txt file
echo "[record images] Writing tags to $IMAGES_DIR/images.txt"
printf "%s\n" "$@" > "$IMAGES_DIR/images.txt"
printf "%s --platform=$DOCKER_PLATFORM \n" "$@" > "$IMAGES_DIR/images.txt"

# Execute git commit
echo "[commit images] Start git commit:"
Expand Down
2 changes: 1 addition & 1 deletion images.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@

node:lts --platform=linux/arm64
14 changes: 12 additions & 2 deletions sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ fi

failed_count=0
failed_images=""
while IFS= read -r image; do
while IFS= read -r image_and_platform; do
# Check if platform information is present
if [[ "$image_and_platform" == *"--platform="* ]]; then
# Extract platform information and image name
image=$(echo "$image_and_platform" | sed -e "s/--platform=[^ ]*//g" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
platform_arg=$(echo "$image_and_platform" | grep -o -- "--platform=[^ ]*")
else
# No platform information
image="$image_and_platform"
platform_arg=""
fi
# 拉取镜像
set +e
docker pull "$image"
docker pull "$image" $platform_arg
pull_status=$?
if [ $pull_status -ne 0 ]; then
echo "Error: Failed to pull image $image, continuing..."
Expand Down