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
docker compose --file compose-dev.yaml up --detach
9
11
```
10
12
11
-
**Visual Studio Code -> Run and Debug -> api** (or `uv run -- fastapi dev src/python_template/api/main.py`)
13
+
**Run project:**
14
+
15
+
> Visual Studio Code -> Run and Debug -> api
16
+
17
+
(or `uv run -- fastapi dev src/python_template/api/main.py`)
18
+
19
+
**Destroy environment:**
12
20
13
21
```bash
14
22
docker compose --file compose-dev.yaml down --volumes
15
23
```
16
24
17
-
# Reasonings
18
-
19
-
## Settings and .env files
25
+
# Settings and .env files
20
26
21
-
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.
27
+
The API must be deployed to several environments (development, staging, production...), but each company uses different environments (from one to any number), so the API is the only one that knows the number of environments and their names.
22
28
Then, each environment has its own settings (e.g., the logging level or URL of an external service may vary between environments).
23
29
24
30
So, we'll use this rules to store settings:
25
-
- Store settings in `.env` files.
26
31
- A `.env` file for common settings.
27
32
- A `.env.{environment}` file for each environment.
28
33
- If a setting is in both `.env` and `.env.{environment}`, the one in `.env.{environment}` takes precedence.
29
34
30
-
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.
35
+
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 API (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