소스 검색

Create registry-proxy

Stille 3 년 전
부모
커밋
33b6d7d677
4개의 변경된 파일73개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      registry-proxy/Dockerfile
  2. 32 0
      registry-proxy/README.md
  3. 12 0
      registry-proxy/docker-compose.yml
  4. 22 0
      registry-proxy/entrypoint.sh

+ 7 - 0
registry-proxy/Dockerfile

@@ -0,0 +1,7 @@
+FROM registry:latest
+LABEL maintainer="Stille <[email protected]>"
+
+ENV PROXY_REMOTE_URL="" \
+    DELETE_ENABLED=""
+
+COPY entrypoint.sh /entrypoint.sh

+ 32 - 0
registry-proxy/README.md

@@ -0,0 +1,32 @@
+# mc
+
+GitHub [stilleshan/dockerfiles](https://github.com/stilleshan/dockerfiles)  
+Docker [stilleshan/registry-proxy](https://hub.docker.com/r/stilleshan/registry-proxy)
+> *docker image support for X86 and ARM*
+
+## 简介
+代理 ghcr.io / gcr.io / k8s.gcr.io 等镜像仓库的 registry proxy 镜像.
+
+## 使用
+### docker
+环境变量`PROXY_REMOTE_URL`:
+- https://ghcr.io
+- https://gcr.io
+- https://k8s.gcr.io
+
+```shell
+docker run -d --restart always \
+    -v /data/path:/var/lib/registry\
+    -p 5000:5000 \
+    -e PROXY_REMOTE_URL=https://ghcr.io \
+    stilleshan/registry-proxy
+```
+
+### docker compose
+下载 [docker-compose.yml](https://raw.githubusercontent.com/stilleshan/dockerfiles/main/registry-proxy/docker-compose.yml) 执行以下命令启动:
+```shell
+docker-compose up -d
+```
+
+## 参考
+- GitHub [findsec-cn/registry-proxy](https://github.com/findsec-cn/registry-proxy)

+ 12 - 0
registry-proxy/docker-compose.yml

@@ -0,0 +1,12 @@
+version: "3"
+services:
+  ghcr.io:
+    image: stilleshan/registry-proxy
+    volumes:
+      - ./data:/var/lib/registry
+      - /etc/localtime:/etc/localtime
+    ports:
+      - 5000:5000
+    environment:
+      - PROXY_REMOTE_URL=https://ghcr.io
+    restart: always

+ 22 - 0
registry-proxy/entrypoint.sh

@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+CONFIG_YML=/etc/docker/registry/config.yml
+
+if [ -n "$PROXY_REMOTE_URL" -a `grep -c "$PROXY_REMOTE_URL" $CONFIG_YML` -eq 0 ]; then
+    echo "proxy:" >> $CONFIG_YML
+    echo "  remoteurl: $PROXY_REMOTE_URL" >> $CONFIG_YML
+    echo "------ Enabled proxy to remote: $PROXY_REMOTE_URL ------"
+elif [ $DELETE_ENABLED = true -a `grep -c "delete:" $CONFIG_YML` -eq 0 ]; then
+    sed -i '/rootdirectory/a\  delete:' $CONFIG_YML
+    sed -i '/delete/a\    enabled: true' $CONFIG_YML
+    echo "------ Enabled local storage delete -----"
+fi
+
+case "$1" in
+    *.yaml|*.yml) set -- registry serve "$@" ;;
+    serve|garbage-collect|help|-*) set -- registry "$@" ;;
+esac
+
+exec "$@"