From d3d9f78820028601c2dc74d0e92e49b0b6c49c28 Mon Sep 17 00:00:00 2001 From: WJQSERVER Date: Wed, 9 Oct 2024 20:53:50 +0800 Subject: [PATCH] 1.4.1 --- .github/workflows/.build-alpine.yaml | 96 ---------------------------- .github/workflows/build.yml | 2 +- CHANGELOG.md | 7 ++ VERSION | 2 +- docker/dockerfile/dev/Dockerfile | 2 +- docker/dockerfile/dev/Dockerfile.bak | 23 ------- docker/dockerfile/release/Dockerfile | 4 +- docker/dockerfile/release/init.sh | 25 ++++---- 8 files changed, 24 insertions(+), 137 deletions(-) delete mode 100644 .github/workflows/.build-alpine.yaml delete mode 100644 docker/dockerfile/dev/Dockerfile.bak diff --git a/.github/workflows/.build-alpine.yaml b/.github/workflows/.build-alpine.yaml deleted file mode 100644 index 06fcba4..0000000 --- a/.github/workflows/.build-alpine.yaml +++ /dev/null @@ -1,96 +0,0 @@ -name: Build Alpine Dev - -on: - workflow_dispatch: - push: - branches: - - 'main' - paths: - - 'DEV-VERSION' - -jobs: - build: - runs-on: ubuntu-latest - env: - OUTPUT_BINARY: ghproxy-alpine - OUTPUT_ARCHIVE: ghproxy-alpine.tar.gz - GO_VERSION: 1.23.2 - - steps: - - uses: actions/checkout@v3 - - name: Load VERSION - run: | - if [ -f DEV-VERSION ]; then - echo "VERSION=$(cat DEV-VERSION)" >> $GITHUB_ENV - else - echo "DEV-VERSION file not found!" && exit 1 - fi - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: ${{ env.GO_VERSION }} - - name: Build - run: | - CGO_ENABLED=0 go build -o ${{ env.OUTPUT_BINARY }} ./main.go - - name: Package - run: | - tar -czvf ${{ env.OUTPUT_ARCHIVE }} ./${{ env.OUTPUT_BINARY }} - - name: Upload to GitHub Artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.OUTPUT_BINARY }} - path: | - ./${{ env.OUTPUT_ARCHIVE }} - ./${{ env.OUTPUT_BINARY }} - - name: 上传至Release - id: create_release - uses: ncipollo/release-action@v1 - with: - name: ${{ env.VERSION }} - artifacts: ./${{ env.OUTPUT_ARCHIVE }}, ./${{ env.OUTPUT_BINARY }} - token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ env.VERSION }} - allowUpdates: true - prerelease: true - env: - export PATH: $PATH:/usr/local/go/bin - - docker: - runs-on: ubuntu-latest - needs: build - env: - IMAGE_NAME: wjqserver/ghproxy - DOCKERFILE: docker/dockerfile/alpine/Dockerfile - - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Load VERSION - run: | - if [ -f DEV-VERSION ]; then - echo "VERSION=$(cat DEV-VERSION)" >> $GITHUB_ENV - else - echo "DEV-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@v5 - with: - file: ./${{ env.DOCKERFILE }} - platforms: linux/amd64 - push: true - tags: | - ${{ env.IMAGE_NAME }}:alpine-${{ env.VERSION }} - ${{ env.IMAGE_NAME }}:alpine-dev diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16d392f..527e502 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: Build run: | - go build -o ${{ env.OUTPUT_BINARY }} ./main.go + CGO_ENABLED=0 go build -o ${{ env.OUTPUT_BINARY }} ./main.go - name: Package run: | tar -czvf ${{ env.OUTPUT_ARCHIVE }} ./${{ env.OUTPUT_BINARY }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 177f6a1..844f7f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # 更新日志 +v1.4.1 +--- +- CHANGE: 优化代码结构,提升性能 +- CHANGE: 引入Alpine Linux作为基础镜像,减少Docker镜像体积 +- FIX: 修正部分参数错误 +- CHANGE: CGO_ENABLED=0 + 24w12c --- - PRE-RELEASE: 此版本是v1.4.1的预发布版本,请勿在生产环境中使用 diff --git a/VERSION b/VERSION index e21e727..13175fd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.0 \ No newline at end of file +1.4.1 \ No newline at end of file diff --git a/docker/dockerfile/dev/Dockerfile b/docker/dockerfile/dev/Dockerfile index e16e6e8..a12bb4c 100644 --- a/docker/dockerfile/dev/Dockerfile +++ b/docker/dockerfile/dev/Dockerfile @@ -11,7 +11,7 @@ RUN wget -O /data/www/index.html https://raw.githubusercontent.com/${USER}/${REP RUN wget -O /data/www/favicon.ico https://raw.githubusercontent.com/${USER}/${REPO}/main/pages/favicon.ico RUN wget -O /data/caddy/Caddyfile https://raw.githubusercontent.com/${USER}/${REPO}/main/caddyfile/release/Caddyfile RUN VERSION=$(curl -s https://raw.githubusercontent.com/${USER}/${REPO}/main/DEV-VERSION) && \ - wget -O /data/${APPLICATION}/${APPLICATION} https://github.com/${USER}/${REPO}/releases/download/$VERSION/ghproxy + wget -O /data/${APPLICATION}/${APPLICATION} https://github.com/${USER}/${REPO}/releases/download/$VERSION/${APPLICATION} RUN wget -O /data/${APPLICATION}/config.yaml https://raw.githubusercontent.com/${USER}/${REPO}/main/config/config.yaml 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 diff --git a/docker/dockerfile/dev/Dockerfile.bak b/docker/dockerfile/dev/Dockerfile.bak deleted file mode 100644 index 04d7a63..0000000 --- a/docker/dockerfile/dev/Dockerfile.bak +++ /dev/null @@ -1,23 +0,0 @@ -FROM wjqserver/caddy:daily - -ARG USER=WJQSERVER-STUDIO -ARG REPO=ghproxy -ARG APPLICATION=ghproxy - -RUN mkdir -p /data/www -RUN mkdir -p /data/${APPLICATION}/config -RUN mkdir -p /data/${APPLICATION}/log -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 wget -O /data/caddy/Caddyfile https://raw.githubusercontent.com/${USER}/${REPO}/main/caddyfile/release/Caddyfile -RUN VERSION=$(curl -s https://raw.githubusercontent.com/${USER}/${REPO}/main/DEV-VERSION) && \ - wget -O /data/${APPLICATION}/${APPLICATION} https://github.com/${USER}/${REPO}/releases/download/$VERSION/${APPLICATION} -RUN wget -O /data/${APPLICATION}/config.yaml https://raw.githubusercontent.com/${USER}/${REPO}/main/config/config.yaml -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 wget -O /usr/local/bin/init.sh https://raw.githubusercontent.com/${USER}/${REPO}/main/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/release/Dockerfile b/docker/dockerfile/release/Dockerfile index bca9044..6f7d5a0 100644 --- a/docker/dockerfile/release/Dockerfile +++ b/docker/dockerfile/release/Dockerfile @@ -1,4 +1,4 @@ -FROM wjqserver/caddy:latest +FROM wjqserver/caddy:alpine ARG USER=WJQSERVER-STUDIO ARG REPO=ghproxy @@ -15,7 +15,7 @@ RUN VERSION=$(curl -s https://raw.githubusercontent.com/${USER}/${REPO}/main/VER RUN wget -O /data/${APPLICATION}/config.yaml https://raw.githubusercontent.com/${USER}/${REPO}/main/config/config.yaml 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 wget -O /usr/local/bin/init.sh https://raw.githubusercontent.com/${USER}/${REPO}/main/init.sh +RUN wget -O /usr/local/bin/init.sh https://raw.githubusercontent.com/${USER}/${REPO}/main/docker/dockerfile/release/init.sh RUN chmod +x /data/${APPLICATION}/${APPLICATION} RUN chmod +x /usr/local/bin/init.sh diff --git a/docker/dockerfile/release/init.sh b/docker/dockerfile/release/init.sh index 86db1e1..a4dea96 100644 --- a/docker/dockerfile/release/init.sh +++ b/docker/dockerfile/release/init.sh @@ -1,28 +1,27 @@ -#!/bin/bash +#!/bin/sh -APPLICATON=ghproxy +APPLICATION=ghproxy if [ ! -f /data/caddy/config/Caddyfile ]; then cp /data/caddy/Caddyfile /data/caddy/config/Caddyfile fi -if [ ! -f /data/${APPLICATON}/config/blacklist.json ]; then - cp /data/${APPLICATON}/blacklist.json /data/${APPLICATON}/config/blacklist.json +if [ ! -f /data/${APPLICATION}/config/blacklist.json ]; then + cp /data/${APPLICATION}/blacklist.json /data/${APPLICATION}/config/blacklist.json fi -if [ ! -f /data/${APPLICATON}/config/whitelist.json ]; then - cp /data/${APPLICATON}/whitelist.json /data/${APPLICATON}/config/whitelist.json +if [ ! -f /data/${APPLICATION}/config/whitelist.json ]; then + cp /data/${APPLICATION}/whitelist.json /data/${APPLICATION}/config/whitelist.json fi -if [ ! -f /data/${APPLICATON}/config/config.yaml ]; then - cp /data/${APPLICATON}/config.yaml /data/${APPLICATON}/config/config.yaml +if [ ! -f /data/${APPLICATION}/config/config.yaml ]; then + cp /data/${APPLICATION}/config.yaml /data/${APPLICATION}/config/config.yaml fi -/data/caddy/caddy run --config /data/caddy/config/Caddyfile > /data/${APPLICATON}/log/caddy.log 2>&1 & +/data/caddy/caddy run --config /data/caddy/config/Caddyfile > /data/${APPLICATION}/log/caddy.log 2>&1 & -/data/${APPLICATON}/${APPLICATON} > /data/ghproxy/log/run.log 2>&1 & +/data/${APPLICATION}/${APPLICATION} > /data/${APPLICATION}/log/run.log 2>&1 & -while [[ true ]]; do +while true; do sleep 1 -done - +done \ No newline at end of file