This commit is contained in:
WJQSERVER 2024-10-09 20:53:50 +08:00
parent f3a49b83f2
commit d3d9f78820
8 changed files with 24 additions and 137 deletions

View file

@ -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

View file

@ -31,7 +31,7 @@ jobs:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
- name: Build - name: Build
run: | run: |
go build -o ${{ env.OUTPUT_BINARY }} ./main.go CGO_ENABLED=0 go build -o ${{ env.OUTPUT_BINARY }} ./main.go
- name: Package - name: Package
run: | run: |
tar -czvf ${{ env.OUTPUT_ARCHIVE }} ./${{ env.OUTPUT_BINARY }} tar -czvf ${{ env.OUTPUT_ARCHIVE }} ./${{ env.OUTPUT_BINARY }}

View file

@ -1,5 +1,12 @@
# 更新日志 # 更新日志
v1.4.1
---
- CHANGE: 优化代码结构,提升性能
- CHANGE: 引入Alpine Linux作为基础镜像,减少Docker镜像体积
- FIX: 修正部分参数错误
- CHANGE: CGO_ENABLED=0
24w12c 24w12c
--- ---
- PRE-RELEASE: 此版本是v1.4.1的预发布版本,请勿在生产环境中使用 - PRE-RELEASE: 此版本是v1.4.1的预发布版本,请勿在生产环境中使用

View file

@ -1 +1 @@
1.4.0 1.4.1

View file

@ -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/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 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) && \ 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}/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}/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 /data/${APPLICATION}/whitelist.json https://raw.githubusercontent.com/${USER}/${REPO}/main/config/whitelist.json

View file

@ -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"]

View file

@ -1,4 +1,4 @@
FROM wjqserver/caddy:latest FROM wjqserver/caddy:alpine
ARG USER=WJQSERVER-STUDIO ARG USER=WJQSERVER-STUDIO
ARG REPO=ghproxy 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}/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}/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 /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 /data/${APPLICATION}/${APPLICATION}
RUN chmod +x /usr/local/bin/init.sh RUN chmod +x /usr/local/bin/init.sh

View file

@ -1,28 +1,27 @@
#!/bin/bash #!/bin/sh
APPLICATON=ghproxy APPLICATION=ghproxy
if [ ! -f /data/caddy/config/Caddyfile ]; then if [ ! -f /data/caddy/config/Caddyfile ]; then
cp /data/caddy/Caddyfile /data/caddy/config/Caddyfile cp /data/caddy/Caddyfile /data/caddy/config/Caddyfile
fi fi
if [ ! -f /data/${APPLICATON}/config/blacklist.json ]; then if [ ! -f /data/${APPLICATION}/config/blacklist.json ]; then
cp /data/${APPLICATON}/blacklist.json /data/${APPLICATON}/config/blacklist.json cp /data/${APPLICATION}/blacklist.json /data/${APPLICATION}/config/blacklist.json
fi fi
if [ ! -f /data/${APPLICATON}/config/whitelist.json ]; then if [ ! -f /data/${APPLICATION}/config/whitelist.json ]; then
cp /data/${APPLICATON}/whitelist.json /data/${APPLICATON}/config/whitelist.json cp /data/${APPLICATION}/whitelist.json /data/${APPLICATION}/config/whitelist.json
fi fi
if [ ! -f /data/${APPLICATON}/config/config.yaml ]; then if [ ! -f /data/${APPLICATION}/config/config.yaml ]; then
cp /data/${APPLICATON}/config.yaml /data/${APPLICATON}/config/config.yaml cp /data/${APPLICATION}/config.yaml /data/${APPLICATION}/config/config.yaml
fi 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 sleep 1
done done