跳转到内容

二次开发与构建

hubproxy/
├── src/ # Go 后端(main.go、handlers、config、utils)
├── web/ # Vue 前端 SPA
├── Dockerfile # 多阶段构建
└── docs/ # 文档站

GitHub / Hugging Face 等 URL 前缀代理由 src/handlers/github.gogithubExps 控制:

var githubExps = []*regexp.Regexp{
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:releases|archive)/.*`),
// 在此追加新正则
}

要求:

  1. 正则需含 ([^/]+)/([^/]+) 捕获组,供 [access] 匹配 owner/repo
  2. 运行 go test ./handlers/...
  3. 路由已在 main.goNoRoute(GitHubProxyHandler) 注册,新域名无需加路由

访问控制逻辑:src/utils/access_control.goCheckGitHubAccess

config.toml[registries],认证扩展点在 src/handlers/docker.gocreateUpstreamOptions()

src/main.gobuildRouter() 注册。

Terminal window
cd src && CONFIG_PATH=./config.toml go run .
cd web && npm ci && npm run dev

生产嵌入前端:

Terminal window
cd web && npm ci && npm run build
# 将 dist 复制到 src/dist
cd ../src && go build -o hubproxy .
Terminal window
docker build -t hubproxy:local --build-arg VERSION=1.0.0 .
docker buildx build --platform linux/amd64,linux/arm64 \
-t ghcr.io/your-org/hubproxy:latest \
--build-arg VERSION=1.0.0 --push .
阶段 镜像 作用
frontend node:24-alpine 构建 Vue
builder golang:1.26-alpine 编译 + UPX
final alpine 运行时
Terminal window
cd src && go test ./...

CI:.github/workflows/docker-ghcr.yml(镜像)、release.yml(安装包)。