diff --git a/README.md b/README.md index 5d233764..772892d7 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # cloudflare-docker-proxy -![deploy](https://github.com/ciiiii/cloudflare-docker-proxy/actions/workflows/deploy.yaml/badge.svg) +![deploy](https://github.com/dereking/cloudflare-docker-proxy/actions/workflows/deploy.yaml/badge.svg) -[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/ciiiii/cloudflare-docker-proxy) +[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/dereking/cloudflare-docker-proxy) -> If you're looking for proxy for helm, maybe you can try [cloudflare-helm-proxy](https://github.com/ciiiii/cloudflare-helm-proxy). +> If you're looking for proxy for helm, maybe you can try [cloudflare-helm-proxy](https://github.com/dereking/cloudflare-helm-proxy). ## Deploy @@ -12,7 +12,7 @@ 2. follow the instructions to fork and deploy 3. update routes as you requirement -[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/ciiiii/cloudflare-docker-proxy) +[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/dereking/cloudflare-docker-proxy) ## Routes configuration tutorial diff --git a/src/help.html b/src/help.html new file mode 100644 index 00000000..666dec53 --- /dev/null +++ b/src/help.html @@ -0,0 +1,140 @@ + + + + + + 镜像使用说明 + + + + +
+

镜像使用说明

+ + 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.{{host}}/library/nginx:latest  # 拉取 Docker 官方镜像
+
+# docker pull quay.io/coreos/etcd:latest
+docker pull quay.{{host}}/coreos/etcd:latest  # 拉取 Quay 镜像
+
+# docker pull gcr.io/google-containers/busybox:latest
+docker pull gcr.{{host}}/google-containers/busybox:latest  # 拉取 GCR 镜像
+
+# docker pull k8s.gcr.io/pause:latest
+docker pull k8s-gcr.{{host}}/pause:latest  # 拉取 k8s.gcr.io 镜像
+
+# docker pull registry.k8s.io/pause:latest
+docker pull k8s.{{host}}/pause:latest  # 拉取 registry.k8s.io 镜像
+
+# docker pull ghcr.io/github/super-linter:latest
+docker pull ghcr.{{host}}/github/super-linter:latest  # 拉取 GitHub 容器镜像
+
+# docker pull docker.cloudsmith.io/public/repo/image:latest
+docker pull cloudsmith.{{host}}/public/repo/image:latest  # 拉取 Cloudsmith 镜像
+
+

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

+
+
+ + + + \ No newline at end of file diff --git a/src/index.js b/src/index.js index 97b08852..e4589725 100644 --- a/src/index.js +++ b/src/index.js @@ -5,19 +5,22 @@ addEventListener("fetch", (event) => { const dockerHub = "https://registry-1.docker.io"; +import DOCS from './help.html' + + const routes = { // production - "docker.libcuda.so": dockerHub, - "quay.libcuda.so": "https://quay.io", - "gcr.libcuda.so": "https://gcr.io", - "k8s-gcr.libcuda.so": "https://k8s.gcr.io", - "k8s.libcuda.so": "https://registry.k8s.io", - "ghcr.libcuda.so": "https://ghcr.io", - "cloudsmith.libcuda.so": "https://docker.cloudsmith.io", - "ecr.libcuda.so": "https://public.ecr.aws", + "docker.ked.pub": dockerHub, + "quay.ked.pub": "https://quay.io", + "gcr.ked.pub": "https://gcr.io", + "k8s-gcr.ked.pub": "https://k8s.gcr.io", + "k8s.ked.pub": "https://registry.k8s.io", + "ghcr.ked.pub": "https://ghcr.io", + "cloudsmith.ked.pub": "https://docker.cloudsmith.io", + "ecr.ked.pub": "https://public.ecr.aws", // staging - "docker-staging.libcuda.so": dockerHub, + "docker-staging.ked.pub": dockerHub, }; function routeByHosts(host) { @@ -45,6 +48,17 @@ async function handleRequest(request) { } const isDockerHub = upstream == dockerHub; const authorization = request.headers.get("Authorization"); + + // return docs +if (url.pathname === "/") { + return new Response(DOCS, { + status: 200, + headers: { + "content-type": "text/html" + } + }); +} + if (url.pathname == "/v2/") { const newUrl = new URL(upstream + "/v2/"); const headers = new Headers(); diff --git a/wrangler.toml b/wrangler.toml index c3077a0f..ba138af1 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -13,13 +13,13 @@ TARGET_UPSTREAM = "https://registry-1.docker.io" [env.production] name = "cloudflare-docker-proxy" # routes = [ -# { pattern = "docker.libcuda.so", custom_domain = true }, -# { pattern = "quay.libcuda.so", custom_domain = true }, -# { pattern = "gcr.libcuda.so", custom_domain = true }, -# { pattern = "k8s-gcr.libcuda.so", custom_domain = true }, -# { pattern = "k8s.libcuda.so", custom_domain = true }, -# { pattern = "ghcr.libcuda.so", custom_domain = true }, -# { pattern = "cloudsmith.libcuda.so", custom_domain = true }, +# { pattern = "docker.ked.pub", custom_domain = true }, +# { pattern = "quay.ked.pub", custom_domain = true }, +# { pattern = "gcr.ked.pub", custom_domain = true }, +# { pattern = "k8s-gcr.ked.pub", custom_domain = true }, +# { pattern = "k8s.ked.pub", custom_domain = true }, +# { pattern = "ghcr.ked.pub", custom_domain = true }, +# { pattern = "cloudsmith.ked.pub", custom_domain = true }, # ] [env.production.vars] @@ -28,7 +28,7 @@ TARGET_UPSTREAM = "" [env.staging] name = "cloudflare-docker-proxy-staging" -# route = { pattern = "docker-staging.libcuda.so", custom_domain = true } +# route = { pattern = "docker-staging.ked.pub", custom_domain = true } [env.staging.vars] MODE = "staging"