From ac537dc555dd3ee822d603e6d1638e95820264a8 Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Sun, 19 Jan 2025 20:38:02 +0800 Subject: [PATCH] update to v2 --- .github/workflows/build.yml | 42 +--------------------- CHANGELOG.md | 8 +++++ README.md | 4 ++- VERSION | 2 +- deploy/config.toml | 1 + docker/dockerfile/nocache/Dockerfile | 52 --------------------------- docker/dockerfile/nocache/config.toml | 37 ------------------- docker/dockerfile/nocache/init.sh | 25 ------------- docker/dockerfile/release/Dockerfile | 8 ++--- 9 files changed, 18 insertions(+), 161 deletions(-) delete mode 100644 docker/dockerfile/nocache/Dockerfile delete mode 100644 docker/dockerfile/nocache/config.toml delete mode 100644 docker/dockerfile/nocache/init.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2fb7132..bf7b32b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,44 +101,4 @@ jobs: push: true tags: | ${{ env.IMAGE_NAME }}:${{ env.VERSION }} - ${{ env.IMAGE_NAME }}:latest - - docker-nocache: - runs-on: ubuntu-latest - needs: build # 确保这个作业在 build 作业完成后运行 - env: - IMAGE_NAME: wjqserver/ghproxy # 定义镜像名称变量 - DOCKERFILE: docker/dockerfile/nocache/Dockerfile # 定义 Dockerfile 路径变量 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Load VERSION - run: | - if [ -f VERSION ]; then - echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV - else - echo "VERSION file not found!" && exit 1 - fi - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: 构建镜像 - uses: docker/build-push-action@v6 - with: - file: ./${{ env.DOCKERFILE }} - platforms: linux/amd64,linux/arm64 - push: true - tags: | - ${{ env.IMAGE_NAME }}:${{ env.VERSION }}-nocache - ${{ env.IMAGE_NAME }}:nocache \ No newline at end of file + ${{ env.IMAGE_NAME }}:latest \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b6a1d1..d3e0f0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # 更新日志 +2.0.0 +--- +- RELEASE: v2.0.0正式版发布; 此版本圆了几个月前画的饼, 在大文件下载的内存占用方面做出了巨大改进 +- CHANGE: 优化`proxy`核心模块, 使用Chuncked Buffer传输数据, 减少内存占用 +- REMOVE: caddy +- REMOVE: nocache +- CHANGE: 优化前端页面, 增加更多功能(来自1.8.1版本, 原本也是为v2所设计的) + 25w04c --- - PRE-RELEASE: 此版本是v2的候选版本,请勿在生产环境中使用; diff --git a/README.md b/README.md index 03ca5ac..0f974e4 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ wget -O install.sh https://raw.githubusercontent.com/WJQSERVER-STUDIO/ghproxy/ma host = "127.0.0.1" # 监听地址 port = 8080 # 监听端口 sizeLimit = 125 # 125MB +bufferSize = 4096 # Bytes 缓冲区大小 enableH2C = "on" # 是否开启H2C传输(latest和dev版本请开启) on/off [pages] @@ -159,7 +160,8 @@ example.com { ### 前端页面 -![ghproxy-demo.png](https://webp.wjqserver.com/ghproxy/ghproxy-demo-v1.7.0-mobile-night.png) +![ghproxy-demo.png](https://webp.wjqserver.com/ghproxy/1.8.1-light.png) +![ghproxy-demo-dark.png](https://webp.wjqserver.com/ghproxy/1.8.1-dark.png) 结语 --- diff --git a/VERSION b/VERSION index fe4e75f..359a5b9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.3 \ No newline at end of file +2.0.0 \ No newline at end of file diff --git a/deploy/config.toml b/deploy/config.toml index 6053f12..cc49eff 100644 --- a/deploy/config.toml +++ b/deploy/config.toml @@ -2,6 +2,7 @@ host = "127.0.0.1" port = 8080 sizeLimit = 125 # MB +bufferSize = 4096 # Bytes enableH2C = false debug = false diff --git a/docker/dockerfile/nocache/Dockerfile b/docker/dockerfile/nocache/Dockerfile deleted file mode 100644 index 2d7327b..0000000 --- a/docker/dockerfile/nocache/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -FROM alpine:latest AS builder - -ARG USER=WJQSERVER-STUDIO -ARG REPO=ghproxy -ARG APPLICATION=ghproxy -ARG TARGETOS -ARG TARGETARCH -ARG TARGETPLATFORM - -# 创建文件夹 -RUN mkdir -p /data/www -RUN mkdir -p /data/${APPLICATION}/config -RUN mkdir -p /data/${APPLICATION}/log - -# 安装依赖 -RUN apk add --no-cache curl wget tar - -# 前端 -RUN wget -O /data/www/index.html https://raw.githubusercontent.com/${USER}/${REPO}/main/pages/index.html -RUN wget -O /data/www/favicon.ico https://raw.githubusercontent.com/${USER}/${REPO}/main/pages/favicon.ico - -# 后端 -RUN VERSION=$(curl -s https://raw.githubusercontent.com/${USER}/${REPO}/main/VERSION) && \ - wget -O /data/${APPLICATION}/${APPLICATION}-${TARGETOS}-${TARGETARCH}.tar.gz https://github.com/${USER}/${REPO}/releases/download/$VERSION/${APPLICATION}-${TARGETOS}-${TARGETARCH}.tar.gz && \ - tar -zxvf /data/${APPLICATION}/${APPLICATION}-${TARGETOS}-${TARGETARCH}.tar.gz -C /data/${APPLICATION} && \ - rm -rf /data/${APPLICATION}/${APPLICATION}-${TARGETOS}-${TARGETARCH}.tar.gz -RUN wget -O /usr/local/bin/init.sh https://raw.githubusercontent.com/${USER}/${REPO}/main/docker/dockerfile/nocache/init.sh - -# 拉取配置 -#RUN wget -O /data/caddy/Caddyfile https://raw.githubusercontent.com/${USER}/${REPO}/main/caddyfile/nocache/Caddyfile -RUN wget -O /data/${APPLICATION}/config.toml https://raw.githubusercontent.com/${USER}/${REPO}/main/docker/dockerfile/nocache/config.toml -RUN wget -O /data/${APPLICATION}/blacklist.json https://raw.githubusercontent.com/${USER}/${REPO}/main/config/blacklist.json -RUN wget -O /data/${APPLICATION}/whitelist.json https://raw.githubusercontent.com/${USER}/${REPO}/main/config/whitelist.json - -# 权限 -RUN chmod +x /data/${APPLICATION}/${APPLICATION} -RUN chmod +x /usr/local/bin/init.sh - -FROM alpine:latest - -RUN apk add --no-cache curl - -COPY --from=builder /data/www /data/www -COPY --from=builder /data/${APPLICATION} /data/${APPLICATION} -COPY --from=builder /usr/local/bin/init.sh /usr/local/bin/init.sh - -# 权限 -RUN chmod +x /data/${APPLICATION}/${APPLICATION} -RUN chmod +x /usr/local/bin/init.sh - -CMD ["/usr/local/bin/init.sh"] - diff --git a/docker/dockerfile/nocache/config.toml b/docker/dockerfile/nocache/config.toml deleted file mode 100644 index 32abf6e..0000000 --- a/docker/dockerfile/nocache/config.toml +++ /dev/null @@ -1,37 +0,0 @@ -[server] -host = "0.0.0.0" -port = 80 #修改此配置会导致容器异常 -sizeLimit = 125 # MB -enableH2C = "off" # on / off -debug = false - -[pages] -enabled = false -staticDir = "/data/www" - -[log] -logFilePath = "/data/ghproxy/log/ghproxy.log" -maxLogSize = 5 # MB - -[cors] -enabled = true - -[auth] -authMethod = "parameters" # "header" or "parameters" -authToken = "token" -enabled = false -passThrough = false - -[blacklist] -blacklistFile = "/data/ghproxy/config/blacklist.json" -enabled = false - -[whitelist] -enabled = false -whitelistFile = "/data/ghproxy/config/whitelist.json" - -[rateLimit] -enabled = false -rateMethod = "total" # "ip" or "total" -ratePerMinute = 180 -burst = 5 diff --git a/docker/dockerfile/nocache/init.sh b/docker/dockerfile/nocache/init.sh deleted file mode 100644 index 27a153f..0000000 --- a/docker/dockerfile/nocache/init.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -APPLICATION=ghproxy - -if [ ! -f /data/${APPLICATION}/config/blacklist.json ]; then - cp /data/${APPLICATION}/blacklist.json /data/${APPLICATION}/config/blacklist.json -fi - -if [ ! -f /data/${APPLICATION}/config/whitelist.json ]; then - cp /data/${APPLICATION}/whitelist.json /data/${APPLICATION}/config/whitelist.json -fi - -if [ ! -f /data/${APPLICATION}/config/config.toml ]; then - cp /data/${APPLICATION}/config.toml /data/${APPLICATION}/config/config.toml -fi - -/data/${APPLICATION}/${APPLICATION} -cfg /data/${APPLICATION}/config/config.toml > /data/${APPLICATION}/log/run.log 2>&1 & - -sleep 30 - -while [[ true ]]; do - # Failure Circuit Breaker - curl -f --max-time 5 -retry 3 http://127.0.0.1:80/api/healthcheck || exit 1 - sleep 120 -done \ No newline at end of file diff --git a/docker/dockerfile/release/Dockerfile b/docker/dockerfile/release/Dockerfile index aec8282..411646e 100644 --- a/docker/dockerfile/release/Dockerfile +++ b/docker/dockerfile/release/Dockerfile @@ -1,4 +1,4 @@ -FROM wjqserver/caddy:2.9.1-alpine AS builder +FROM alpine:latest AS builder ARG USER=WJQSERVER-STUDIO ARG REPO=ghproxy @@ -27,7 +27,7 @@ RUN VERSION=$(curl -s https://raw.githubusercontent.com/${USER}/${REPO}/main/VER RUN wget -O /usr/local/bin/init.sh https://raw.githubusercontent.com/${USER}/${REPO}/main/docker/dockerfile/release/init.sh # 拉取配置 -RUN wget -O /data/caddy/Caddyfile https://raw.githubusercontent.com/${USER}/${REPO}/main/caddyfile/release/Caddyfile +#RUN wget -O /data/caddy/Caddyfile https://raw.githubusercontent.com/${USER}/${REPO}/main/caddyfile/release/Caddyfile RUN wget -O /data/${APPLICATION}/config.toml https://raw.githubusercontent.com/${USER}/${REPO}/main/config/config.toml RUN wget -O /data/${APPLICATION}/blacklist.json https://raw.githubusercontent.com/${USER}/${REPO}/main/config/blacklist.json RUN wget -O /data/${APPLICATION}/whitelist.json https://raw.githubusercontent.com/${USER}/${REPO}/main/config/whitelist.json @@ -36,12 +36,12 @@ RUN wget -O /data/${APPLICATION}/whitelist.json https://raw.githubusercontent.co RUN chmod +x /data/${APPLICATION}/${APPLICATION} RUN chmod +x /usr/local/bin/init.sh -FROM wjqserver/caddy:2.9.1-alpine +FROM alpine:latest RUN apk add --no-cache curl COPY --from=builder /data/www /data/www -COPY --from=builder /data/caddy /data/caddy +#COPY --from=builder /data/caddy /data/caddy COPY --from=builder /data/${APPLICATION} /data/${APPLICATION} COPY --from=builder /usr/local/bin/init.sh /usr/local/bin/init.sh