From 261014d24d1ec4eaf769a0cd4f5ef8b40e96def5 Mon Sep 17 00:00:00 2001 From: Egor Aristov Date: Mon, 10 Feb 2025 11:03:21 +0300 Subject: [PATCH] yaml configuration removed to simplify deploy and development --- README.md | 8 +++----- config.yml | 3 --- internal/config/config.go | 10 +++++----- 3 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 config.yml diff --git a/README.md b/README.md index 844ddd1..b6fda86 100644 --- a/README.md +++ b/README.md @@ -45,14 +45,12 @@ For SSL, authentication, domains, etc. - use Caddy or Nginx (no specific configu ### Configuration -Configuration is done using [config.yml](config.yml) file or env vars - -Env vars always has precedence over config.yml - -Docker-compose deployment uses [deploy/.env file](deploy/.env) +Configuration is done using environment variables You can see all available options in [config.go file](internal/config/config.go) (struct Config) +Docker-compose deployment uses [deploy/.env file](deploy/.env) + ### Scaling Each worker can process 1 page at a time, so to scale you should run multiple worker instances. This is done using replicas parameter in worker section in [docker-compose.yml file](deploy/docker-compose.yml) diff --git a/config.yml b/config.yml deleted file mode 100644 index ee5202b..0000000 --- a/config.yml +++ /dev/null @@ -1,3 +0,0 @@ -webserver_address: "0.0.0.0:5000" -nats_url: "nats://localhost:4222" -debug: true diff --git a/internal/config/config.go b/internal/config/config.go index 04f4d75..f5bf732 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -10,15 +10,15 @@ import ( ) type Config struct { - WebserverAddress string `yaml:"webserver_address" env:"WEBSERVER_ADDRESS" env-required:"true" validate:"hostname_port"` - NatsUrl string `yaml:"nats_url" env:"NATS_URL" env-required:"true" validate:"url"` - Debug bool `yaml:"debug" env:"DEBUG"` - Proxy string `yaml:"proxy" env:"PROXY" env-default:"" validate:"omitempty,proxy"` + WebserverAddress string `env:"WEBSERVER_ADDRESS" env-default:"0.0.0.0:5000" validate:"hostname_port"` + NatsUrl string `env:"NATS_URL" env-default:"nats://localhost:4222" validate:"url"` + Debug bool `env:"DEBUG"` + Proxy string `env:"PROXY" env-default:"" validate:"omitempty,proxy"` } func Read() (Config, error) { var cfg Config - err := cleanenv.ReadConfig("config.yml", &cfg) + err := cleanenv.ReadEnv(&cfg) if err != nil { return Config{}, err }