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: backend/README.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,29 +3,29 @@
3
3
## Requirements
4
4
5
5
*[Docker](https://www.docker.com/).
6
-
*[Poetry](https://python-poetry.org/) for Python package and environment management.
6
+
*[uv](https://docs.astral.sh/uv/) for Python package and environment management.
7
7
8
8
## Docker Compose
9
9
10
10
Start the local development environment with Docker Compose following the guide in [../development.md](../development.md).
11
11
12
12
## General Workflow
13
13
14
-
By default, the dependencies are managed with [Poetry](https://python-poetry.org/), go there and install it.
14
+
By default, the dependencies are managed with [uv](https://docs.astral.sh/uv/), go there and install it.
15
15
16
16
From `./backend/` you can install all the dependencies with:
17
17
18
18
```console
19
-
$ poetry install
19
+
$ uv sync
20
20
```
21
21
22
-
Then you can start a shell session with the new environment with:
22
+
Then you can activate the virtual environment with:
23
23
24
24
```console
25
-
$ poetry shell
25
+
$ source .venv/bin/activate
26
26
```
27
27
28
-
Make sure your editor is using the correct Python virtual environment.
28
+
Make sure your editor is using the correct Python virtual environment, with the interpreter at `backend/.venv/bin/python`.
29
29
30
30
Modify or add SQLModel models for data and SQL tables in `./backend/app/models.py`, API endpoints in `./backend/app/api/`, CRUD (Create, Read, Update, Delete) utils in `./backend/app/crud.py`.
31
31
@@ -41,23 +41,23 @@ During development, you can change Docker Compose settings that will only affect
41
41
42
42
The changes to that file only affect the local development environment, not the production environment. So, you can add "temporary" changes that help the development workflow.
43
43
44
-
For example, the directory with the backend code is mounted as a Docker "host volume", mapping the code you change live to the directory inside the container. That allows you to test your changes right away, without having to build the Docker image again. It should only be done during development, for production, you should build the Docker image with a recent version of the backend code. But during development, it allows you to iterate very fast.
44
+
For example, the directory with the backend code is synchronized in the Docker container, copying the code you change live to the directory inside the container. That allows you to test your changes right away, without having to build the Docker image again. It should only be done during development, for production, you should build the Docker image with a recent version of the backend code. But during development, it allows you to iterate very fast.
45
45
46
-
There is also a command override that runs `/start-reload.sh` (included in the base image) instead of the default `/start.sh` (also included in the base image). It starts a single server process (instead of multiple, as would be for production) and reloads the process whenever the code changes. Have in mind that if you have a syntax error and save the Python file, it will break and exit, and the container will stop. After that, you can restart the container by fixing the error and running again:
46
+
There is also a command override that runs `fastapi run --reload`instead of the default `fastapi run`. It starts a single server process (instead of multiple, as would be for production) and reloads the process whenever the code changes. Have in mind that if you have a syntax error and save the Python file, it will break and exit, and the container will stop. After that, you can restart the container by fixing the error and running again:
47
47
48
48
```console
49
-
$ docker compose up -d
49
+
$ docker compose watch
50
50
```
51
51
52
52
There is also a commented out `command` override, you can uncomment it and comment the default one. It makes the backend container run a process that does "nothing", but keeps the container alive. That allows you to get inside your running container and execute commands inside, for example a Python interpreter to test installed dependencies, or start the development server that reloads when it detects changes.
53
53
54
54
To get inside the container with a `bash` session you can start the stack with:
55
55
56
56
```console
57
-
$ docker compose up -d
57
+
$ docker compose watch
58
58
```
59
59
60
-
and then `exec` inside the running container:
60
+
and then in another terminal, `exec` inside the running container:
61
61
62
62
```console
63
63
$ docker compose exec backend bash
@@ -71,16 +71,16 @@ root@7f2607af31c3:/app#
71
71
72
72
that means that you are in a `bash` session inside your container, as a `root` user, under the `/app` directory, this directory has another directory called "app" inside, that's where your code lives inside the container: `/app/app`.
73
73
74
-
There you can use the script `/start-reload.sh`to run the debug live reloading server. You can run that script from inside the container with:
74
+
There you can use the `fastapi run --reload` command to run the debug live reloading server.
75
75
76
76
```console
77
-
$ bash /start-reload.sh
77
+
$ fastapi run --reload app/main.py
78
78
```
79
79
80
80
...it will look like:
81
81
82
82
```console
83
-
root@7f2607af31c3:/app# bash /start-reload.sh
83
+
root@7f2607af31c3:/app# fastapi run --reload app/main.py
84
84
```
85
85
86
86
and then hit enter. That runs the live reloading server that auto reloads when it detects code changes.
0 commit comments