Skip to content

Commit

Permalink
Set default Docker directories
Browse files Browse the repository at this point in the history
  • Loading branch information
JackDallas committed Jun 4, 2022
1 parent f1b43bc commit 93c6503
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/premiumizearrd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ func main() {

config, err := config.LoadOrCreateConfig(configFile)

// Override config data directories if running in docker
if utils.IsRunningInDockerContainer() {
if config.BlackholeDirectory == "" {
config.BlackholeDirectory = "/blackhole"
}
if config.DownloadsDirectory == "" {
config.DownloadsDirectory = "/downloads"
}
if config.UnzipDirectory == "" {
config.UnzipDirectory = "/unzip"
}
}

if err != nil {
panic(err)
}
Expand Down
13 changes: 13 additions & 0 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,16 @@ func EnvOrDefault(envName string, defaultValue string) string {
}
return envValue
}

func IsRunningInDockerContainer() bool {
// docker creates a .dockerenv file at the root
// of the directory tree inside the container.
// if this file exists then the viewer is running
// from inside a container so return true

if _, err := os.Stat("/.dockerenv"); err == nil {
return true
}

return false
}

0 comments on commit 93c6503

Please sign in to comment.