Skip to Content
Getting StartedConfiguration

Configuration

Configuration files are written in YAML.

config/config.yml
production: frontend_url: "${FRONTEND_URL:http://localhost:3000}" database: type: postgres host: "${DATABASE_HOST}" port: ${DATABASE_PORT:5432} username: "${DATABASE_USERNAME}" password: "${DATABASE_PASSWORD}" database: "${DATABASE_NAME}" ssl_mode: "${DATABASE_SSL_MODE}" server: host: "${SERVER_HOST}" port: "${SERVER_PORT:8080}" url: "${SERVER_URL}" worker: type: temporal temporal_address: "${WORKER_TEMPORAL_ADDRESS}" temporal_namespace: "${WORKER_TEMPORAL_NAMESPACE}" temporal_task_queue: "${WORKER_TEMPORAL_TASK_QUEUE}" mail: host: "${MAIL_HOST}" port: ${MAIL_PORT:1025} username: "${MAIL_USERNAME}" password: "${MAIL_PASSWORD}" auth_type: "${MAIL_AUTH_TYPE:login}" tls_policy: "${MAIL_TLS_POLICY:opportunistic}" default_from: "${MAIL_FROM}" storage: type: s3 bucket: "${STORAGE_BUCKET}" region: "${STORAGE_REGION}" access_key_id: "${STORAGE_ACCESS_KEY_ID}" secret_access_key: "${STORAGE_SECRET_ACCESS_KEY}" endpoint: "${STORAGE_ENDPOINT}" secure: ${STORAGE_SECURE:true} logging: level: "${LOG_LEVEL}" i18n: &i18n default_locale: "en" supported_locales: ["en"] fallback_locale: ["en"] folder: "config/i18n" package: "i18n"

Environment Variables

Environment variables can be referenced using the ${VAR} syntax. Values inside ${...} are expanded from your shell environment when the application starts. The default value can be set using the : syntax, e.g. ${VAR:default}.

If the variable is not present the string will be as it is, so if ${VAR} is not set, the value will be ${VAR} not an empty string.

Go code

config/config.go
package config var ( EnvProduction Env = "production" EnvDevelopment Env = "development" EnvTest Env = "test" ) type Environment struct { FrontendUrl string `yaml:"frontend_url"` Database configuration.Database `yaml:"database"` Server configuration.Server `yaml:"server"` Logging configuration.Logging `yaml:"logging"` Storage configuration.Storage `yaml:"storage"` Worker configuration.Worker `yaml:"worker"` Mail configuration.Mail `yaml:"mail"` I18n configuration.I18n `yaml:"i18n"` } type Config struct { Production Environment `yaml:"production"` Development Environment `yaml:"development"` Test Environment `yaml:"test"` Env Env `yaml:"current_environment"` }

This is the base config that is generated. configuration is a package in core, that contains the structs used to parse the configuration file. You can extend it to add your own configuration structs, and then use them in your config file.

This file cames with a function to parse the configuration file and return a Config. Also some helpers function to get based on the config the current environment for each part of the configuration.

Last updated on