Environment

Env Vars

Environment variables are evaluated in the following order to allow flexibility when running in production:

  1. .env file
  2. environment variables
  3. cmd flags (if available)

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