Configuration¶
Setup¶
Env File¶
Usually a .env
file is created in the directory projects/sbos-playground
.
The file can be used to configure the playground server.
Warning
Make sure you place the .env
file in the correct directory.
Example
If the default server port should be changed from 9000
to 10000
,
the following line can be added in the .env
file:
Environment Variables¶
Alternatively, environment variables can also be used, and its priority is higher.
Other¶
Configuration can also be setup in other places.
For detailed environment variables precedence rules, check the section Environment Variables Precedence.
Configuration List¶
Note
If docker-compose is used to deploy the service, and the configuration entry is not listed in the compose file, the entry should be added to the "environment" section manually.
There are three types of configurations:
- Database: Database connection
- Authorization: JWT, CORS, OAuth2
- Backend: Server host, port, url, and etc.
Environment Variables Precedence¶
The order of precedence (highest to lowest) is as follows:
- Set using docker compose run -e in the CLI.
- Set with either the environment or env_file attribute but with the value interpolated from your shell or an environment file. (either your default .env file, or with the --env-file argument in the CLI).
- Set using just the environment attribute in the Compose file.
- Use of the env_file attribute in the Compose file.
- Set in a container image in the ENV directive. Having any ARG or ENV setting in a Dockerfile evaluates only if there is no Docker Compose entry for environment, env_file or run --env.
Source: https://docs.docker.com/compose/environment-variables/envvars-precedence
Even when using a dotenv file, pydantic will still read environment variables as well as the dotenv file, environment variables will always take priority over values loaded from a dotenv file.
Source: https://docs.pydantic.dev/latest/concepts/pydantic_settings/#dotenv-env-support