From 3870bf579cfe4cf095fa685d8b5865fc008c576b Mon Sep 17 00:00:00 2001 From: lixd Date: Wed, 12 Jun 2024 17:20:19 +0800 Subject: [PATCH] add docs site --- src/index.js | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/src/index.js b/src/index.js index 37209d00..eba35b75 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,136 @@ +const DOCS=` + + + + + + 镜像使用说明 + + + + +
+

镜像使用说明

+ + GitHub + +
+
+
+

为了加速 Docker 镜像拉取,你可以使用以下命令设置 registry mirror:

+
sudo tee /etc/docker/daemon.json <<EOF
+{
+    "registry-mirrors": ["https://{{host}}"]
+}
+EOF
+# 配置完后需要重启 Docker 服务
+sudo systemctl restart docker
+
+

使用该代理从不同的镜像仓库拉取镜像,请参考以下命令:

+

+# docker pull nginx:latest
+docker pull docker.lixd.xyz/library/nginx:latest  # 拉取 Docker 官方镜像
+
+# docker pull quay.io/coreos/etcd:latest
+docker pull quay.lixd.xyz/coreos/etcd:latest  # 拉取 Quay 镜像
+
+# docker pull gcr.io/google-containers/busybox:latest
+docker pull gcr.lixd.xyz/google-containers/busybox:latest  # 拉取 GCR 镜像
+
+# docker pull k8s.gcr.io/pause:latest
+docker pull k8s-gcr.lixd.xyz/pause:latest  # 拉取 k8s.gcr.io 镜像
+
+# docker pull registry.k8s.io/pause:latest
+docker pull k8s.lixd.xyz/pause:latest  # 拉取 registry.k8s.io 镜像
+
+# docker pull ghcr.io/github/super-linter:latest
+docker pull ghcr.lixd.xyz/github/super-linter:latest  # 拉取 GitHub 容器镜像
+
+# docker pull docker.cloudsmith.io/public/repo/image:latest
+docker pull cloudsmith.lixd.xyz/public/repo/image:latest  # 拉取 Cloudsmith 镜像
+
+

为了避免 Worker 用量耗尽,你可以手动 pull 镜像然后 re-tag 之后 push 至本地镜像仓库。

+
+
+ + + + +` + addEventListener("fetch", (event) => { event.passThroughOnException(); event.respondWith(handleRequest(event.request)); @@ -36,6 +169,17 @@ async function handleRequest(request) { } ); } + + // return docs + if (url.pathname === "/") { + return new Response(DOCS.replace(/{{host}}/g, url.hostname), { + status: 200, + headers: { + "content-type": "text/html" + } + }); + } + // check if need to authenticate if (url.pathname == "/v2/") { const newUrl = new URL(upstream + "/v2/");