diff --git a/.github/workflows/build-alpine.yaml b/.github/workflows/build-alpine.yaml new file mode 100644 index 0000000..06fcba4 --- /dev/null +++ b/.github/workflows/build-alpine.yaml @@ -0,0 +1,96 @@ +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/CHANGELOG.md b/CHANGELOG.md index baac7c4..5855781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # 更新日志 +24w12b +--- +- PRE-RELEASE: 此版本是v1.4.1的预发布版本,请勿在生产环境中使用 +- CHANGE: 优化代码结构,提升性能 +- CHANGE: 尝试引入Alpine Linux作为基础镜像,减少镜像体积 + +24w12a +--- +- PRE-RELEASE: 此版本是v1.4.1的预发布版本,请勿在生产环境中使用 +- CHANGE: 优化代码结构,提升性能 +- FIX: 修正部分参数错误 +- CHANGE: CGO_ENABLED=0 + v1.4.0 --- - CHANGE: 优化代码结构,提升性能 diff --git a/docker/dockerfile/alpine/Dockerfile b/docker/dockerfile/alpine/Dockerfile new file mode 100644 index 0000000..feaa800 --- /dev/null +++ b/docker/dockerfile/alpine/Dockerfile @@ -0,0 +1,23 @@ +FROM wjqserver/caddy:daily-alpine + +ARG USER=WJQSERVER-STUDIO +ARG REPO=ghproxy +ARG APPLICATION=ghproxy-alpine + +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/docker/dockerfile/alpine/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/alpine/init.sh b/docker/dockerfile/alpine/init.sh new file mode 100644 index 0000000..a4dea96 --- /dev/null +++ b/docker/dockerfile/alpine/init.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +APPLICATION=ghproxy + +if [ ! -f /data/caddy/config/Caddyfile ]; then + cp /data/caddy/Caddyfile /data/caddy/config/Caddyfile +fi + +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.yaml ]; then + cp /data/${APPLICATION}/config.yaml /data/${APPLICATION}/config/config.yaml +fi + +/data/caddy/caddy run --config /data/caddy/config/Caddyfile > /data/${APPLICATION}/log/caddy.log 2>&1 & + +/data/${APPLICATION}/${APPLICATION} > /data/${APPLICATION}/log/run.log 2>&1 & + +while true; do + sleep 1 +done \ No newline at end of file