Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chendelin1982 authored Oct 28, 2024
1 parent b6099b3 commit 75a47e2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 87 deletions.
79 changes: 0 additions & 79 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,85 +10,6 @@ on:
- dev

jobs:
ProxyCheck:
name: ProxyCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Read and process dockerhub-proxy.md
id: read_file
run: |
# Read the file and process each line
urls=()
while IFS= read -r line; do
# Remove '- https://' prefix and any trailing whitespace, and append to urls array
url=$(echo "${line/- https:\/\//}" | tr -d '\r')
urls+=("$url")
done < docs/reference/_include/dockerhub-proxy.md
# Print the array for debugging
echo "Processed URLs: ${urls[@]}"
# Join the array elements with a space to form a single string
urls_string=$(IFS=' '; echo "${urls[*]}")
# Save the string to the outputs
echo "::set-output name=urls::$urls_string"
- name: Docker pull from proxies
run: |
# Read the URLs from the previous step
urls="${{ steps.read_file.outputs.urls }}"
IFS=' ' read -r -a url_array <<< "$urls"
# Define the size of the image in MB
image_size_mb=501
# Try to pull the image from each URL
for url in "${url_array[@]}"; do
echo "Trying to pull from $url/library/mysql:5.7"
# Get the start time
start_time=$(date +%s)
# Attempt to pull the image
if docker pull "$url/library/mysql:5.7"; then
# Get the end time
end_time=$(date +%s)
# Calculate the duration in seconds
duration=$((end_time - start_time))
# Calculate the pull rate in MB/s
if [ $duration -gt 0 ]; then
pull_rate=$(echo "scale=2; $image_size_mb / $duration" | bc)
else
pull_rate=0
fi
# Check if the pull rate is less than 1 MB/s
if (( $(echo "$pull_rate < 1" | bc -l) )); then
echo "Pull rate is less than 1 MB/s, marking as failure"
exit 1
else
echo "Successfully pulled from $url"
fi
# Delete the pulled image to ensure fresh pull for the next URL
docker rmi "$url/library/mysql:5.7"
else
echo "--------------Failed to pull from $url--------------"
pull_rate=0
fi
# Always check if the pull rate is less than 1 MB/s
if (( $(echo "$pull_rate < 1" | bc -l) )); then
echo "Pull rate is less than 1 MB/s, marking as failure"
exit 1
fi
echo "--------------Final pull rate($url): $pull_rate MB/s-------------"
done

# Spellcheck:
# name: Spellcheck
Expand Down
1 change: 1 addition & 0 deletions docs/reference/_include/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Readme
4 changes: 0 additions & 4 deletions docs/reference/_include/dockerhub-proxy.md

This file was deleted.

5 changes: 1 addition & 4 deletions docs/reference/repos.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ sidebar_position: 3
slug: /software-repos
---

import Meta from './_include/dockerhub-proxy.md';


# 软件仓库

## DockerHub 代理加速{#dockerhub-proxy}

Docker Hub **代理加速地址**用于加速镜像下载,提高速度和可靠性,解决镜像访问问题。

<Meta name="meta" />

- [DockerHub 国内加速镜像列表](https://github.com/dongyubin/DockerHub)

## 容器镜像{#docker}

Expand Down

0 comments on commit 75a47e2

Please sign in to comment.