mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-09 07:54:03 +02:00
moved env to .env.example, update setup method
This commit is contained in:
parent
91e012987e
commit
46b4090629
4 changed files with 30 additions and 18 deletions
22
.env.example
Normal file
22
.env.example
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# set timezone to get correct log timestamp
|
||||||
|
TZ=ETC/UTC
|
||||||
|
|
||||||
|
# generate secret with `openssl rand -base64 32`
|
||||||
|
GOPROXY_API_JWT_SECRET=
|
||||||
|
|
||||||
|
# the JWT token time-to-live
|
||||||
|
GOPROXY_API_JWT_TOKEN_TTL=1h
|
||||||
|
|
||||||
|
# API/WebUI login credentials
|
||||||
|
GOPROXY_API_USER=admin
|
||||||
|
GOPROXY_API_PASSWORD=password
|
||||||
|
|
||||||
|
# Proxy listening address
|
||||||
|
GOPROXY_HTTP_ADDR=:80
|
||||||
|
GOPROXY_HTTPS_ADDR=:443
|
||||||
|
|
||||||
|
# API listening address
|
||||||
|
GOPROXY_API_ADDR=127.0.0.1:8888
|
||||||
|
|
||||||
|
# Debug mode
|
||||||
|
GOPROXY_DEBUG=false
|
|
@ -4,31 +4,19 @@ services:
|
||||||
container_name: go-proxy-frontend
|
container_name: go-proxy-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
network_mode: host
|
network_mode: host
|
||||||
|
env_file: .env
|
||||||
depends_on:
|
depends_on:
|
||||||
- app
|
- app
|
||||||
# if you also want to proxy the WebUI and access it via gp.y.z
|
# if you also want to proxy the WebUI and access it via gp.y.z
|
||||||
# labels:
|
# labels:
|
||||||
# - proxy.aliases=gp
|
# - proxy.aliases=gp
|
||||||
# - proxy.gp.port=3000
|
# - proxy.gp.port=3000
|
||||||
|
|
||||||
# Make sure the value is same as `GOPROXY_API_ADDR` below (if you have changed it)
|
|
||||||
#
|
|
||||||
# environment:
|
|
||||||
# GOPROXY_API_ADDR: 127.0.0.1:8888
|
|
||||||
app:
|
app:
|
||||||
image: ghcr.io/yusing/go-proxy:latest
|
image: ghcr.io/yusing/go-proxy:latest
|
||||||
container_name: go-proxy
|
container_name: go-proxy
|
||||||
restart: always
|
restart: always
|
||||||
network_mode: host
|
network_mode: host
|
||||||
environment:
|
env_file: .env
|
||||||
# (Optional) change this to your timezone to get correct log timestamp
|
|
||||||
TZ: ETC/UTC
|
|
||||||
|
|
||||||
# Change these if you need
|
|
||||||
#
|
|
||||||
# GOPROXY_HTTP_ADDR: :80
|
|
||||||
# GOPROXY_HTTPS_ADDR: :443
|
|
||||||
# GOPROXY_API_ADDR: 127.0.0.1:8888
|
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- ./config:/app/config
|
- ./config:/app/config
|
||||||
|
|
|
@ -13,7 +13,8 @@ const (
|
||||||
// file, folder structure
|
// file, folder structure
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DotEnvPath = ".env"
|
DotEnvPath = ".env"
|
||||||
|
DotEnvExamplePath = ".env.example"
|
||||||
|
|
||||||
ConfigBasePath = "config"
|
ConfigBasePath = "config"
|
||||||
ConfigFileName = "config.yml"
|
ConfigFileName = "config.yml"
|
||||||
|
|
|
@ -16,6 +16,7 @@ var (
|
||||||
baseURL = "https://github.com/yusing/go-proxy/raw/" + branch
|
baseURL = "https://github.com/yusing/go-proxy/raw/" + branch
|
||||||
requiredConfigs = []Config{
|
requiredConfigs = []Config{
|
||||||
{common.ConfigBasePath, true, false, ""},
|
{common.ConfigBasePath, true, false, ""},
|
||||||
|
{common.DotEnvPath, false, true, common.DotEnvExamplePath},
|
||||||
{common.ComposeFileName, false, true, common.ComposeExampleFileName},
|
{common.ComposeFileName, false, true, common.ComposeExampleFileName},
|
||||||
{path.Join(common.ConfigBasePath, common.ConfigFileName), false, true, common.ConfigExampleFileName},
|
{path.Join(common.ConfigBasePath, common.ConfigFileName), false, true, common.ConfigExampleFileName},
|
||||||
}
|
}
|
||||||
|
@ -40,7 +41,7 @@ func Setup() {
|
||||||
config.setup()
|
config.setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("done")
|
log.Println("setup finished")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) setup() {
|
func (c *Config) setup() {
|
||||||
|
@ -96,7 +97,7 @@ func fetch(remoteFilename string, outFileName string) {
|
||||||
log.Printf("%q already exists, downloading to %q\n", outFileName, remoteFilename)
|
log.Printf("%q already exists, downloading to %q\n", outFileName, remoteFilename)
|
||||||
outFileName = remoteFilename
|
outFileName = remoteFilename
|
||||||
}
|
}
|
||||||
log.Printf("downloading %q\n", remoteFilename)
|
log.Printf("downloading %q to %q\n", remoteFilename, outFileName)
|
||||||
|
|
||||||
url, err := url.JoinPath(baseURL, remoteFilename)
|
url, err := url.JoinPath(baseURL, remoteFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -120,7 +121,7 @@ func fetch(remoteFilename string, outFileName string) {
|
||||||
log.Fatalf("failed to write to file: %s\n", err)
|
log.Fatalf("failed to write to file: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("downloaded to %q\n", outFileName)
|
log.Print("done")
|
||||||
|
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue