File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -1013,6 +1013,17 @@ docker run \
10131013timothyye/godns:latest
10141014```
10151015
1016+ To run it with a ` YAML ` config file:
1017+
1018+ ``` bash
1019+ docker run \
1020+ -d --name godns \
1021+ -e CONFIG=/config.yaml \
1022+ --restart=always \
1023+ -v /path/to/config.yaml:/config.yaml \
1024+ timothyye/godns:latest
1025+ ```
1026+
10161027### As a Windows service
10171028
101810291 . Download the latest version of [ NSSM] ( https://nssm.cc/download )
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ import (
1414 "github.com/fatih/color"
1515)
1616
17+ const (
18+ configEnv = "CONFIG"
19+ )
20+
1721var (
1822 configuration settings.Settings
1923 optConf = flag .String ("c" , "./config.json" , "Specify a config file" )
@@ -28,15 +32,24 @@ func init() {
2832}
2933
3034func main () {
35+
3136 flag .Parse ()
3237 if * optHelp {
3338 color .Cyan (utils .Logo , Version )
3439 flag .Usage ()
3540 return
3641 }
3742
43+ configPath := * optConf
44+
45+ // read config path from the environment
46+ if os .Getenv (configEnv ) != "" {
47+ // overwrite the config path
48+ configPath = os .Getenv (configEnv )
49+ }
50+
3851 // Load settings from configurations file
39- if err := settings .LoadSettings (* optConf , & configuration ); err != nil {
52+ if err := settings .LoadSettings (configPath , & configuration ); err != nil {
4053 log .Fatal (err )
4154 }
4255
You can’t perform that action at this time.
0 commit comments