Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd7491aaa7 | ||
|
|
b11a864495 | ||
|
|
564364db74 | ||
|
|
a1f0eaafa6 | ||
|
|
2bbb539dda | ||
|
|
7ba2b94a00 | ||
|
|
5e764a6cd7 | ||
|
|
abeb6ee8eb |
96
.github/workflows/.build-alpine.yaml
vendored
Normal file
96
.github/workflows/.build-alpine.yaml
vendored
Normal file
@@ -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
|
||||
2
.github/workflows/build-dev.yml
vendored
2
.github/workflows/build-dev.yml
vendored
@@ -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 }}
|
||||
|
||||
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
@@ -66,12 +66,11 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
- name: Load VERSION
|
||||
run: |
|
||||
if [ -f DEV-VERSION ]; then
|
||||
echo "VERSION=$(cat DEV-VERSION)" >> $GITHUB_ENV
|
||||
if [ -f VERSION ]; then
|
||||
echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
|
||||
else
|
||||
echo "DEV-VERSION file not found!" && exit 1
|
||||
fi
|
||||
|
||||
echo "VERSION file not found!" && exit 1
|
||||
fi
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,5 +1,24 @@
|
||||
# 更新日志
|
||||
|
||||
24w12c
|
||||
---
|
||||
- PRE-RELEASE: 此版本是v1.4.1的预发布版本,请勿在生产环境中使用
|
||||
- CHANGE: 优化代码结构,提升性能
|
||||
- CHANGE: 尝试在DEV版本引入Alpine Linux作为基础镜像,减少镜像体积
|
||||
|
||||
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: 优化代码结构,提升性能
|
||||
|
||||
@@ -1 +1 @@
|
||||
24w11b
|
||||
24w12c
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
使用Go实现的GHProxy,用于加速部分地区Github仓库的拉取,支持速率限制,用户鉴权,支持Docker部署
|
||||
|
||||
[DEMO](ghproxy.1888866.xyz)
|
||||
[DEMO](https://ghproxy.1888866.xyz)
|
||||
|
||||
## 项目说明
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM wjqserver/caddy:daily
|
||||
FROM wjqserver/caddy:daily-alpine
|
||||
|
||||
ARG USER=WJQSERVER-STUDIO
|
||||
ARG REPO=ghproxy
|
||||
@@ -11,11 +11,11 @@ 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/${APPLICATION}
|
||||
wget -O /data/${APPLICATION}/${APPLICATION} https://github.com/${USER}/${REPO}/releases/download/$VERSION/ghproxy
|
||||
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/alpine/init.sh
|
||||
RUN chmod +x /data/${APPLICATION}/${APPLICATION}
|
||||
RUN chmod +x /usr/local/bin/init.sh
|
||||
|
||||
|
||||
23
docker/dockerfile/dev/Dockerfile.bak
Normal file
23
docker/dockerfile/dev/Dockerfile.bak
Normal file
@@ -0,0 +1,23 @@
|
||||
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"]
|
||||
|
||||
27
docker/dockerfile/dev/init.sh
Normal file
27
docker/dockerfile/dev/init.sh
Normal file
@@ -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
|
||||
28
docker/dockerfile/release/init.sh
Normal file
28
docker/dockerfile/release/init.sh
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
APPLICATON=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
|
||||
fi
|
||||
|
||||
if [ ! -f /data/${APPLICATON}/config/whitelist.json ]; then
|
||||
cp /data/${APPLICATON}/whitelist.json /data/${APPLICATON}/config/whitelist.json
|
||||
fi
|
||||
|
||||
if [ ! -f /data/${APPLICATON}/config/config.yaml ]; then
|
||||
cp /data/${APPLICATON}/config.yaml /data/${APPLICATON}/config/config.yaml
|
||||
fi
|
||||
|
||||
/data/caddy/caddy run --config /data/caddy/config/Caddyfile > /data/${APPLICATON}/log/caddy.log 2>&1 &
|
||||
|
||||
/data/${APPLICATON}/${APPLICATON} > /data/ghproxy/log/run.log 2>&1 &
|
||||
|
||||
while [[ true ]]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
11
main.go
11
main.go
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
||||
"ghproxy/auth"
|
||||
"ghproxy/config"
|
||||
@@ -22,16 +21,6 @@ var (
|
||||
configfile = "/data/ghproxy/config/config.yaml"
|
||||
)
|
||||
|
||||
var (
|
||||
exps = []*regexp.Regexp{
|
||||
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:releases|archive)/.*`),
|
||||
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:blob|raw)/.*`),
|
||||
regexp.MustCompile(`^(?:https?://)?github\.com/([^/]+)/([^/]+)/(?:info|git-).*`),
|
||||
regexp.MustCompile(`^(?:https?://)?raw\.github(?:usercontent|)\.com/([^/]+)/([^/]+)/.+?/.+`),
|
||||
regexp.MustCompile(`^(?:https?://)?gist\.github\.com/([^/]+)/.+?/.+`),
|
||||
}
|
||||
)
|
||||
|
||||
func loadConfig() {
|
||||
var err error
|
||||
// 初始化配置
|
||||
|
||||
Reference in New Issue
Block a user