Environment

Env Vars

Environment variables are evaluated based on the following priority to allow flexibility when running in production, when the earliest priority is met, evaluation stops.

  1. cmd flags
  2. environment variables
  3. .env file

For example, when running go run . start -H 0.0.0.0 while having the value HOST=127.0.0.1 in a .env file, the command value will be evaluated first and that will satisfy the HOST env var, thus preventing futher execution for that env var.

During development, it is recommended to use a .env file. You can find a reference under /.env.sample` to get started.

To ease your development process, we've included a command to print the environment to better understand your app behaviour. Simply run go run . info env. Together with go run . info features, you should be able to get to the bottom of an issue.

List of all available env vars

Var NameRequiredDescription
HOSToptionalservice host address. default: 0.0.0.0
PROTECTED_API_PORToptionalService port. Default: 8080
PUBLIC_API_PORToptionalService port. Default: 8081
HIDDEN_API_PORToptionalService port. Default: 8079
DB_HOSToptionalDatabase host
DB_PORToptionalDatabase port
DB_USERoptionalDatabase username
DB_PASSWORDoptionalDatabase password
DB_NAMEoptionalDatabase name
DB_TIMEZONEoptionalDatabase timezone. Required with Postgres platform
DB_PLATFORMoptionalEnum: ["postgres", "mysql", "sqlite"]. default: "sqlite"
KRATOS_PUBLIC_SERVICEoptionalOry Kratos public API URL
KRATOS_ADMIN_SERVICEoptionalOry Kratos admin API URL
KETO_READ_SERVICEoptionalOry Keto read API URL
KETO_WRITE_SERVICEoptionalOry Keto write API URL
REDIS_HOSToptionalRedis host URL. Required if Redis is enabled
REDIS_PORToptionalRedis port. Required if Redis is enabled
REDIS_PASSWORDoptionalRedis password. Required if Redis is enabled
LOG_LEVELoptionalEnum: ["info", "warn", "debug", "error"]. default: "info"
CORS_ALLOW_ORIGINSoptionalAllowed origins. Default: "*"
REQUEST_TIMEOUT_DURATIONoptionalNumber in seconds. Default: "60"
DISABLE_FEATURESoptionalList of features to disable in runtime, make sure its comma separated without spaces

Was this page helpful?

Consider supporting my work if you find it useful

Buy me a coffee