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
+25-6Lines changed: 25 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,22 +41,41 @@ http://localhost:9000/docs
41
41
42
42

43
43
44
-
## Docker
44
+
## Container
45
45
46
-
This project includes a multi-stage `Dockerfile` for local development and production builds.
46
+
### Docker Compose
47
47
48
-
### Build the image
48
+
This setup uses [Docker Compose](https://docs.docker.com/compose/) to build and run the app and manage a persistent SQLite database stored in a Docker volume.
49
+
50
+
#### Build the image
51
+
52
+
```bash
53
+
docker compose build
54
+
```
55
+
56
+
#### Start the app
49
57
50
58
```bash
51
-
docker build -t python-samples-fastapi-restful .
59
+
docker compose up
52
60
```
53
61
54
-
### Run the container
62
+
> On first run, the container copies a pre-seeded SQLite database into a persistent volume
63
+
> On subsequent runs, that volume is reused and the data is preserved
64
+
65
+
#### Stop the app
55
66
56
67
```bash
57
-
docker run -p 9000:9000 python-samples-fastapi-restful:latest
68
+
docker compose down
58
69
```
59
70
71
+
#### Optional: database reset
72
+
73
+
```bash
74
+
docker compose down -v
75
+
```
76
+
77
+
> This removes the volume and will reinitialize the database from the built-in seed file the next time you `up`.
78
+
60
79
## Credits
61
80
62
81
The solution has been coded using [Visual Studio Code](https://code.visualstudio.com/) with the official [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) extension.
0 commit comments