Skip to content

Commit

Permalink
Move to more flexibility in image
Browse files Browse the repository at this point in the history
  • Loading branch information
bolkedebruin committed Mar 18, 2024
1 parent f75321f commit 91e382c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cmd/rdpgw/config/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/knadh/koanf/providers/file"
"github.com/knadh/koanf/v2"
"log"
"os"
"strings"
)

Expand Down Expand Up @@ -152,16 +153,20 @@ func Load(configFile string) Configuration {
"Caps.TokenAuth": true,
}, "."), nil)

if err := k.Load(file.Provider(configFile), yaml.Parser()); err != nil {
log.Fatalf("Error loading config from file: %v", err)
if _, err := os.Stat(configFile); os.IsNotExist(err) {
log.Printf("Config file %s not found, using defaults and environment", configFile)
} else {
if err := k.Load(file.Provider(configFile), yaml.Parser()); err != nil {
log.Fatalf("Error loading config from file: %v", err)
}
}

if err := k.Load(env.ProviderWithValue("RDPGW_", ".", func(s string, v string) (string, interface{}) {
key := strings.Replace(strings.ToLower(strings.TrimPrefix(s, "RDPGW_")), "__", ".", -1)
key = ToCamel(key)
return key, v
}), nil); err != nil {
log.Fatalf("Error loading config from file: %v", err)
log.Fatalf("Error loading config from environment: %v", err)
}

koanfTag := koanf.UnmarshalConf{Tag: "koanf"}
Expand Down
2 changes: 1 addition & 1 deletion dev/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ COPY --chown=1001 run.sh run.sh
COPY --chown=1001 --from=builder /opt/rdpgw /opt/rdpgw
COPY --chown=1001 --from=builder /etc/passwd /etc/passwd
COPY --chown=1001 --from=builder /etc/ssl/certs /etc/ssl/certs
COPY --chown=1001 rdpgw.yaml /opt/rdpgw/rdpgw.yaml
#COPY --chown=1001 rdpgw.yaml /opt/rdpgw/rdpgw.yaml

WORKDIR /opt/rdpgw
ENTRYPOINT ["/bin/sh", "/run.sh"]

0 comments on commit 91e382c

Please sign in to comment.