You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,15 +18,15 @@ docker compose --file docker-compose-dev.yaml down --volumes
18
18
19
19
# Reasonings
20
20
21
-
## .env files
21
+
## Settings and .env files
22
22
23
-
**Key points:**
23
+
Each backend must be deployed to several environments (development, staging, production...), but each company uses different environments (from one to any number), so the backend is the only one that knows the number of environments and their names.
24
+
Then, each environment has its own settings (e.g., the logging level or URL of an external service may vary between environments).
24
25
25
-
- We store settings in .env files.
26
-
- There's a .env.{environment} file for each environment (Local, Development, Staging, Production).
27
-
- There's a .env file for common settings.
28
-
- If a setting is in both .env and .env.{environment}, the one in .env.{environment} takes precedence.
26
+
So, we'll use this rules to store settings:
27
+
- Store settings in `.env` files.
28
+
- A `.env` file for common settings.
29
+
- A `.env.{environment}` file for each environment.
30
+
- If a setting is in both `.env` and `.env.{environment}`, the one in `.env.{environment}` takes precedence.
29
31
30
-
The typical is to save .env files in the root of the project, but due to some popular tools and libraries (Jupyter, FastAPI, Docker Compose...) load the file `.env` automatically (and an application has its own order, such as giving priority to the current environment, environment variables or a secret store), then we need to store them in another location (in this case, in the "api" folder) and give `ApplicationSettings` the path to the files.
31
-
32
-
Note: Renaming `.env` to `.env.Common` in the root isn't better because if your notebook isn't in the root, you have to specify the path in `ApplicationSettings` anyway, and `Common` can be confusing because it's not an environment.
32
+
Regarding the location of those files, the typical is to save `.env` files in the root of the project, but due to some popular tools and packages (Jupyter, FastAPI, Docker Compose...) load automatically and exclusively the file `.env`, ignoring the environments and the priority order defined by the backend (e.g., `.env.{environment}` has priority over `.env` because it's the current environment), then we need to store the `.env` files in another location (in this case, in the `api` folder) and give the backend the responsibility of loading them, taking into account the environment name.
0 commit comments