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
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -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.
Copy file name to clipboardExpand all lines: development.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
* Start the local stack with Docker Compose:
6
6
7
7
```bash
8
-
docker compose up -d
8
+
docker compose watch
9
9
```
10
10
11
11
* Now you can open your browser and interact with these URLs:
@@ -22,7 +22,7 @@ Traefik UI, to see how the routes are being handled by the proxy: http://localho
22
22
23
23
**Note**: The first time you start your stack, it might take a minute for it to be ready. While the backend waits for the database to be ready and configures everything. You can check the logs to monitor it.
24
24
25
-
To check the logs, run:
25
+
To check the logs, run (in another terminal):
26
26
27
27
```bash
28
28
docker compose logs
@@ -42,7 +42,7 @@ For the backend and frontend, they use the same port that would be used by their
42
42
43
43
This way, you could turn off a Docker Compose service and start its local development service, and everything would keep working, because it all uses the same ports.
44
44
45
-
For example, you can stop that `frontend` service in the Docker Compose:
45
+
For example, you can stop that `frontend` service in the Docker Compose, in another terminal, run:
46
46
47
47
```bash
48
48
docker compose stop frontend
@@ -91,7 +91,7 @@ The domain `localhost.tiangolo.com` is a special domain that is configured (with
91
91
After you update it, run again:
92
92
93
93
```bash
94
-
docker compose up -d
94
+
docker compose watch
95
95
```
96
96
97
97
When deploying, for example in production, the main Traefik is configured outside of the Docker Compose files. For local development, there's an included Traefik in `docker-compose.override.yml`, just to let you test that the domains work as expected, for example with `api.localhost.tiangolo.com` and `dashboard.localhost.tiangolo.com`.
@@ -109,7 +109,7 @@ They also use some additional configurations taken from environment variables se
109
109
After changing variables, make sure you restart the stack:
0 commit comments