mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
24w15a
This commit is contained in:
parent
6864925dbe
commit
69d4d53a51
8 changed files with 102 additions and 16 deletions
32
.github/workflows/build-dev.yml
vendored
32
.github/workflows/build-dev.yml
vendored
|
|
@ -70,6 +70,7 @@ jobs:
|
|||
needs: build
|
||||
env:
|
||||
IMAGE_NAME: wjqserver/ghproxy
|
||||
PROG_NAME: ghproxy
|
||||
DOCKERFILE: docker/dockerfile/dev/Dockerfile
|
||||
|
||||
steps:
|
||||
|
|
@ -95,12 +96,25 @@ jobs:
|
|||
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 }}
|
||||
${{ env.IMAGE_NAME }}:dev
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker buildx build --platform linux/amd64,linux/arm64 -t ${{ env.PROG_NAME }}:dev,${{ env.PROG_NAME }}:${{ env.VERSION }} -f ./${{ env.DOCKERFILE }}
|
||||
|
||||
- name: Install Slim
|
||||
run: |
|
||||
curl -L -o ds.tar.gz https://github.com/slimtoolkit/slim/releases/download/1.40.11/dist_linux.tar.gz
|
||||
tar -xvf ds.tar.gz
|
||||
mv dist_linux/slim /usr/local/bin/
|
||||
mv dist_linux/slim-sensor /usr/local/bin/
|
||||
rm -rf ds.tar.gz dist_linux
|
||||
|
||||
- name: Optimize Docker image using Slim
|
||||
run: |
|
||||
slimlim build --include-path /data --http-probe --continue-after 20 --tag ${{ env.PROG_NAME }}:${{ env.VERSION }} ${{ env.PROG_NAME }}:dev
|
||||
|
||||
- name: Push Docker image
|
||||
run: |
|
||||
docker tag ${{ env.PROG_NAME }}:${{ env.VERSION }} ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
|
||||
docker tag ${{ env.PROG_NAME }}:dev ${{ env.IMAGE_NAME }}:dev
|
||||
docker push ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
|
||||
docker push ${{ env.IMAGE_NAME }}:dev
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
24w14a
|
||||
24w15a
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
/*type Config struct {
|
||||
Server struct {
|
||||
Port int `yaml:"port"`
|
||||
Host string `yaml:"host"`
|
||||
|
|
@ -54,4 +52,52 @@ func loadYAML(filePath string, out interface{}) error {
|
|||
return err
|
||||
}
|
||||
return yaml.Unmarshal(data, out)
|
||||
}*/
|
||||
|
||||
type Config struct {
|
||||
Server ServerConfig
|
||||
Log LoggerConfig
|
||||
CORS CORSConfig
|
||||
Auth AuthConfig
|
||||
Blacklist BlacklistConfig
|
||||
Whitelist WhitelistConfig
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
Port int `toml:"port"`
|
||||
Host string `toml:"host"`
|
||||
SizeLimit int `toml:"sizelimit"`
|
||||
}
|
||||
|
||||
type LoggerConfig struct {
|
||||
LogFilePath string `toml:"logfilepath"`
|
||||
MaxLogSize int `toml:"maxlogsize"`
|
||||
}
|
||||
|
||||
type CORSConfig struct {
|
||||
Enabled bool `toml:"enabled"`
|
||||
}
|
||||
|
||||
type AuthConfig struct {
|
||||
Enabled bool `toml:"enabled"`
|
||||
AuthToken string `toml:"authtoken"`
|
||||
}
|
||||
|
||||
type BlacklistConfig struct {
|
||||
Enabled bool `toml:"enabled"`
|
||||
BlacklistFile string `toml:"blacklistfile"`
|
||||
}
|
||||
|
||||
type WhitelistConfig struct {
|
||||
Enabled bool `toml:"enabled"`
|
||||
WhitelistFile string `toml:"whitelistfile"`
|
||||
}
|
||||
|
||||
// LoadConfig 从 TOML 配置文件加载配置
|
||||
func LoadConfig(filePath string) (*Config, error) {
|
||||
var config Config
|
||||
if _, err := toml.DecodeFile(filePath, &config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &config, nil
|
||||
}
|
||||
|
|
|
|||
23
config/config.toml
Normal file
23
config/config.toml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[server]
|
||||
host = "127.0.0.1"
|
||||
port = 8080
|
||||
sizelimit = 131072000 # 125MB
|
||||
|
||||
[logger]
|
||||
logfilepath = "/data/ghproxy/log/ghproxy.log"
|
||||
maxlogsize = 5 # MB
|
||||
|
||||
[cors]
|
||||
enabled = true
|
||||
|
||||
[auth]
|
||||
authtoken = "test"
|
||||
enabled = false
|
||||
|
||||
[blacklist]
|
||||
blacklistfile = "/data/ghproxy/config/blacklist.json"
|
||||
enabled = false
|
||||
|
||||
[whitelist]
|
||||
enabled = false
|
||||
whitelistfile = "/data/ghproxy/config/whitelist.json"
|
||||
|
|
@ -26,7 +26,7 @@ RUN wget -O /usr/local/bin/init.sh https://raw.githubusercontent.com/${USER}/${R
|
|||
|
||||
# 拉取配置
|
||||
RUN wget -O /data/caddy/Caddyfile https://raw.githubusercontent.com/${USER}/${REPO}/main/caddyfile/dev/Caddyfile
|
||||
RUN wget -O /data/${APPLICATION}/config.yaml https://raw.githubusercontent.com/${USER}/${REPO}/main/config/config.yaml
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ fi
|
|||
|
||||
/data/caddy/caddy run --config /data/caddy/config/Caddyfile > /data/${APPLICATION}/log/caddy.log 2>&1 &
|
||||
|
||||
/data/${APPLICATION}/${APPLICATION} -cfg /data/${APPLICATION}/config/config.yaml > /data/${APPLICATION}/log/run.log 2>&1 &
|
||||
/data/${APPLICATION}/${APPLICATION} -cfg /data/${APPLICATION}/config/config.toml > /data/${APPLICATION}/log/run.log 2>&1 &
|
||||
|
||||
while true; do
|
||||
sleep 1
|
||||
|
|
|
|||
1
go.mod
1
go.mod
|
|
@ -9,6 +9,7 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||
github.com/andybalholm/brotli v1.1.0 // indirect
|
||||
github.com/bytedance/sonic v1.12.3 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.0 // indirect
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -1,3 +1,5 @@
|
|||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
||||
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
|
||||
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
|
||||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue