yaml configuration removed to simplify deploy and development

This commit is contained in:
Egor Aristov 2025-02-10 11:03:21 +03:00
parent 31be767ef1
commit caaf410a70
Signed by: egor3f
GPG Key ID: 40482A264AAEC85F
3 changed files with 8 additions and 13 deletions

View File

@ -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)

View File

@ -1,3 +0,0 @@
webserver_address: "0.0.0.0:5000"
nats_url: "nats://localhost:4222"
debug: true

View File

@ -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
}