cn-coding-mirrors 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/MIRRORS-STATUS.md +47 -0
- package/README.md +345 -2
- package/SECURITY.md +55 -0
- package/package.json +43 -4
- package/scripts/check-mirrors.sh +158 -0
- package/scripts/install.sh +39 -0
- package/skills/cn-coding-mirrors/SKILL.md +58 -0
- package/skills/cn-coding-mirrors/references/ai.md +65 -0
- package/skills/cn-coding-mirrors/references/docker.md +48 -0
- package/skills/cn-coding-mirrors/references/go.md +34 -0
- package/skills/cn-coding-mirrors/references/java.md +69 -0
- package/skills/cn-coding-mirrors/references/misc.md +52 -0
- package/skills/cn-coding-mirrors/references/node.md +54 -0
- package/skills/cn-coding-mirrors/references/python.md +87 -0
- package/skills/cn-coding-mirrors/references/rust.md +38 -0
- package/skills/cn-coding-mirrors/references/system.md +51 -0
- package/skills/cn-coding-mirrors/references/vcs.md +58 -0
- package/skills/docker-pull/SKILL.md +74 -0
- package/skills/docker-pull/scripts/dpull +656 -0
- package/skills/gh-download/SKILL.md +62 -0
- package/skills/gh-download/scripts/ghdl +267 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Rust(cargo / rustup)
|
|
2
|
+
|
|
3
|
+
## cargo 稀疏索引(推荐,无需 git clone 索引)
|
|
4
|
+
|
|
5
|
+
`~/.cargo/config.toml`:
|
|
6
|
+
|
|
7
|
+
```toml
|
|
8
|
+
[source.crates-io]
|
|
9
|
+
replace-with = "rsproxy-sparse"
|
|
10
|
+
|
|
11
|
+
[source.rsproxy-sparse]
|
|
12
|
+
registry = "sparse+https://rsproxy.cn/index/"
|
|
13
|
+
|
|
14
|
+
[registries.rsproxy]
|
|
15
|
+
index = "https://rsproxy.cn/crates.io-index"
|
|
16
|
+
|
|
17
|
+
[net]
|
|
18
|
+
git-fetch-with-cli = true
|
|
19
|
+
retry = 5
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
备选:字节 `https://rsproxy.cn`、中科大 `https://mirrors.ustc.edu.cn/crates.io-index`(git 索引)、
|
|
23
|
+
清华 `sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/`。
|
|
24
|
+
|
|
25
|
+
## rustup / 工具链
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
export RUSTUP_DIST_SERVER="https://rsproxy.cn"
|
|
29
|
+
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 验证
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cargo search serde --limit 1 # 能返回结果说明索引通
|
|
36
|
+
cargo add anyhow --dry-run 2>&1 | head -3
|
|
37
|
+
curl -sI -m 8 https://rsproxy.cn/index/se/rd/serde | head -1
|
|
38
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# 系统包(apt / apk / dnf / brew)
|
|
2
|
+
|
|
3
|
+
## Ubuntu / Debian(apt)
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# 备份再改,永远先备份
|
|
7
|
+
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak.$(date +%F)
|
|
8
|
+
sudo sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g;
|
|
9
|
+
s|http://security.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
|
|
10
|
+
sudo apt update
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Ubuntu 22.04+ 若使用 `/etc/apt/sources.list.d/ubuntu.sources`(deb822 格式),改 `URIs:` 字段。
|
|
14
|
+
24.04 起还可能存在 `ubuntu.sources` + `debian.sources`,注意一并处理。
|
|
15
|
+
|
|
16
|
+
| 源 | URL |
|
|
17
|
+
|---|---|
|
|
18
|
+
| 清华 | `https://mirrors.tuna.tsinghua.edu.cn/ubuntu/` |
|
|
19
|
+
| 阿里云 | `https://mirrors.aliyun.com/ubuntu/` |
|
|
20
|
+
| 中科大 | `https://mirrors.ustc.edu.cn/ubuntu/` |
|
|
21
|
+
| 华为云 | `https://repo.huaweicloud.com/ubuntu/` |
|
|
22
|
+
|
|
23
|
+
## Alpine(apk)
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
sed -i 's|dl-cdn.alpinelinux.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apk/repositories
|
|
27
|
+
apk update
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## CentOS / Rocky / Fedora(dnf/yum)
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
sudo sed -i 's|^mirrorlist=|#mirrorlist=|; s|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|' /etc/yum.repos.d/*.repo
|
|
34
|
+
sudo dnf makecache
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Homebrew
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
|
|
41
|
+
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
|
|
42
|
+
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
|
|
43
|
+
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 验证
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
grep -h '^deb\|^URIs' /etc/apt/sources.list /etc/apt/sources.list.d/*.sources 2>/dev/null | head -3
|
|
50
|
+
sudo apt -o Acquire::http::Timeout=10 update -qq && echo apt-ok
|
|
51
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# 版本控制与代码托管(GitHub 加速、hg、svn)
|
|
2
|
+
|
|
3
|
+
## GitHub 文件下载
|
|
4
|
+
|
|
5
|
+
**不要裸 curl**。用 `ghproxy` 前缀或直接上技能 `gh-download`(分片 + 校验 + 镜像轮转):
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 单文件
|
|
9
|
+
curl -fL -o out.tgz "https://ghproxy.net/https://github.com/owner/repo/releases/download/v1.0.0/asset.tar.gz"
|
|
10
|
+
# 推荐:分片 + sha256 校验 + 自动挑资产
|
|
11
|
+
bash <this-skill-dir>/../gh-download/scripts/ghdl owner/repo@v1.0.0 -a linux-amd64 -o out.tgz -n 8
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
可用代理前缀(实测):`https://ghproxy.net/`、`https://ghfast.top/`、`https://gh-proxy.com/`。
|
|
15
|
+
不可用:`https://ghproxy.cc/`(证书不匹配)、直连 `github.com` release 资产。
|
|
16
|
+
`api.github.com` 可直连(查版本、列资产),只有下载/克隆需要代理。
|
|
17
|
+
|
|
18
|
+
## git clone 加速
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git clone https://ghproxy.net/https://github.com/owner/repo.git
|
|
22
|
+
# 或全局改写(谨慎,会影响所有 https github 地址)
|
|
23
|
+
git config --global url."https://ghproxy.net/https://github.com/".insteadOf "https://github.com/"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
只对特定仓库生效更安全:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git config --global url."https://ghproxy.net/https://github.com/big-org/".insteadOf "https://github.com/big-org/"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Mercurial(hg)
|
|
33
|
+
|
|
34
|
+
hg 没有成熟的国内公共镜像;常见做法是**只镜像单个仓库**或用代理:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# 用 ghproxy 风格企业代理包装任意 https 源
|
|
38
|
+
hg clone https://ghproxy.net/https://hg.example.com/repo
|
|
39
|
+
# 或配置 http_proxy 走本地/公司代理
|
|
40
|
+
hg --config http_proxy.host=127.0.0.1:7890 clone https://hg.mozilla.org/mozilla-central
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
大仓库建议 `--config format.usefncache=0 --config format.usestore=1 --config format.use-share-extension=1` 之外,
|
|
44
|
+
优先考虑官方 `hg.mozilla.org` 的 bundle 发行包(`*.hg` 打包文件),比逐 changeset 拉取快一个数量级。
|
|
45
|
+
|
|
46
|
+
## Subversion(svn)
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
svn checkout https://ghproxy.net/https://github.com/owner/repo/trunk # 仅当仓库暴露 trunk
|
|
50
|
+
# 常用:svn 走公司镜像或 http_proxy
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 验证
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
git ls-remote https://ghproxy.net/https://github.com/sharkdp/fd.git HEAD # 应返回 HEAD sha
|
|
57
|
+
curl -sI -m 8 https://ghfast.top/https://github.com/sharkdp/fd/releases/latest | head -1
|
|
58
|
+
```
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docker-pull
|
|
3
|
+
description: 用国内镜像源按 registry v2 协议分片拉取 Docker/OCI 镜像(ghcr.io、docker.io、gcr.io、quay.io、registry.k8s.io),逐层 sha256 校验后合成镜像并 docker load,绕开直连限速。当 docker pull 卡住/超时、拉 ghcr.io 镜像极慢、或需要离线导出镜像 tar 时使用。Use when `docker pull` stalls or is throttled in mainland China and you need chunked parallel image download through domestic registry mirrors.
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: 需要 python3.8+(仅标准库)与 docker CLI(`--no-load` 时不需要 docker)。目标镜像需可匿名拉取。
|
|
6
|
+
metadata:
|
|
7
|
+
author: cn-coding-mirrors
|
|
8
|
+
scope: china-network
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# docker-pull:国内镜像源分片拉取容器镜像
|
|
12
|
+
|
|
13
|
+
`docker pull ghcr.io/...` 在国内常被限速到几十 KB/s(实测 0.07 MB/s)。本技能直接按 registry v2 API
|
|
14
|
+
拉 manifest 与各 layer,走国内镜像源并发分片,最后按 `docker save` 格式合成并 `docker load`。
|
|
15
|
+
|
|
16
|
+
实测:`ghcr.io/usestrix/strix-sandbox:1.3.0`(1.38 GB / 35 层)**155 秒**完成加载。
|
|
17
|
+
|
|
18
|
+
## 用法
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
python3 scripts/dpull ghcr.io/owner/app:1.2.3 # 下载 + 自动 docker load
|
|
22
|
+
python3 scripts/dpull alpine:3.20 -j 16 -c 8 # 每层 16 分片,每片 8 MiB
|
|
23
|
+
python3 scripts/dpull ghcr.io/o/a:tag --no-load -o /tmp/a.tar # 只产 tar(离线分发/导入他机)
|
|
24
|
+
python3 scripts/dpull nvcr.io/o/a:1 --mirror ghcr.nju.edu.cn --mirror-only
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| 选项 | 说明 |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `-j N` | 每层并发分片数(默认 8) |
|
|
30
|
+
| `-c MB` | 分片大小(默认 16 MiB) |
|
|
31
|
+
| `--platform` | 目标平台,默认 `linux/amd64`(manifest list 里自动挑) |
|
|
32
|
+
| `--mirror HOST` | 追加镜像源;环境变量 `DPULL_MIRRORS` 亦可 |
|
|
33
|
+
| `--mirror-only` | 只用显式指定的镜像源 |
|
|
34
|
+
| `--no-mirror` | 直连官方 registry(境外网络) |
|
|
35
|
+
| `--no-load` | 只生成 tar,不 `docker load` |
|
|
36
|
+
| `-o FILE` / `--keep-tar` | 指定 tar 路径 / 保留 tar |
|
|
37
|
+
| `--cache DIR` | 内容寻址缓存(默认 `~/.cache/dpull`),重复层直接命中 |
|
|
38
|
+
| `-q` | 静默,stdout 只打印镜像引用 |
|
|
39
|
+
|
|
40
|
+
## 内置镜像源链
|
|
41
|
+
|
|
42
|
+
| 官方 registry | 国内镜像(按顺位,失败自动轮转) |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `ghcr.io` | `ghcr.nju.edu.cn`、`ghcr.m.daocloud.io` |
|
|
45
|
+
| `docker.io` | `docker.m.daocloud.io`、`docker.1panel.live`、`hub.rat.dev` |
|
|
46
|
+
| `gcr.io` | `gcr.m.daocloud.io` |
|
|
47
|
+
| `quay.io` | `quay.m.daocloud.io` |
|
|
48
|
+
| `registry.k8s.io` / `k8s.gcr.io` | `k8s.m.daocloud.io` |
|
|
49
|
+
|
|
50
|
+
启动时并发预探测各源,403/连不通的会被剔除并提示;分片失败会轮转到下一个源。
|
|
51
|
+
|
|
52
|
+
## 原理与边界
|
|
53
|
+
|
|
54
|
+
1. `GET /v2/<repo>/manifests/<ref>`(带 `Accept` 协商 OCI index / docker manifest list),按平台选 digest。
|
|
55
|
+
2. 每个 blob(config + 各 layer)先探测大小,再按 Range 分片并发下载,**逐 blob 校验 sha256**。
|
|
56
|
+
3. 组装成 `docker save` 兼容 tar:`blobs/sha256/*` + `manifest.json`(带 RepoTags) + OCI `index.json` + `oci-layout`。
|
|
57
|
+
4. `docker load -i` 导入,标签保持原引用。
|
|
58
|
+
|
|
59
|
+
限制:
|
|
60
|
+
- **仅匿名拉取**(公开镜像)。私有镜像需要 registry token/登录,本脚本不处理。
|
|
61
|
+
- 单 registry 若无任何可用国内镜像,会退回官方直连(可能很慢)。
|
|
62
|
+
- 缓存占磁盘,镜像调完可删 `~/.cache/dpull`。
|
|
63
|
+
|
|
64
|
+
## 何时不要用
|
|
65
|
+
|
|
66
|
+
- 只想配 daemon 级加速且加速器可用:直接改 `/etc/docker/daemon.json` 的 `registry-mirrors`(见技能 `cn-coding-mirrors` 的 `references/docker.md`)。
|
|
67
|
+
- 下载 GitHub release 文件:用技能 `gh-download`。
|
|
68
|
+
|
|
69
|
+
## 验证
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python3 scripts/dpull alpine:3.20 -q # 应输出 alpine:3.20
|
|
73
|
+
docker images alpine --format '{{.Repository}}:{{.Tag}} {{.Size}}'
|
|
74
|
+
```
|