Skip to content

Commit

Permalink
docs: added example docker compose.yaml and infer config file type
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhirn committed Feb 17, 2024
1 parent f99aa22 commit bee678a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
55 changes: 55 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(".", "_"))
Expand Down

0 comments on commit bee678a

Please sign in to comment.