diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..a20d9dd --- /dev/null +++ b/compose.yaml @@ -0,0 +1,55 @@ +name: mta-sts-exporter-example + +configs: + mta-sts-exporter: + content: | + log: + json: true + + reports: + port: 8080 + path: / + maxbodysize: 1048576 + maxjsonsize: 5242880 + save: true + savepath: /tmp/reports + + metrics: + port: 8081 + path: /metrics + go: false + +volumes: + mta-sts-reports: {} + +x-service: &service + restart: unless-stopped + logging: + driver: journald + options: + tag: "{{.Name}}/{{.ID}}" + +x-healthcheck: &healthcheck + start_period: 15s + start_interval: 1s + interval: 15s + timeout: 3s + retries: 3 + +services: + mta-sts-exporter: + <<: *service + image: phiag/mta-sts-exporter:1.1.1 + # allow rootless docker to write to volume + user: 0:0 + ports: + - 127.0.0.1:8080:8080 + - 127.0.0.1:8081:8081 + - "[::1]:8080:8080" + - "[::1]:8081:8081" + environment: + CONFIG_PATH: /mta-sts + configs: + - mta-sts-exporter + volumes: + - mta-sts-reports:/tmp/reports diff --git a/main.go b/main.go index 1f48346..ef81290 100644 --- a/main.go +++ b/main.go @@ -213,9 +213,12 @@ func createConfig() Config { configPath := filepath.Dir(configPathFull) configName := filepath.Base(configPathFull) + if filepath.Ext(configName) == "" { + viper.SetConfigType("yaml") + } + viper.SetConfigName(configName) viper.AddConfigPath(configPath) - viper.SetConfigType("yaml") viper.AutomaticEnv() viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))