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
{{ message }}
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+44-56Lines changed: 44 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,58 +8,33 @@
8
8
9
9
---
10
10
11
-
## Setup development environment
11
+
## Setup development environment (Docker compose)
12
12
13
-
Please install `Docker` and `Docker compose` first.
13
+
Please install [`Docker` and `Docker compose`](https://www.docker.com/) first.
14
14
15
-
https://www.docker.com/
15
+
## Manual setup
16
16
17
17
After installation, run the following command to create a local Docker container.
18
18
19
-
```bash
20
-
docker-compose build
21
-
docker-compose up -d
22
-
```
23
-
24
-
If you want to check the log while Docker container is running, then try to use following command:
25
-
26
-
```bash
19
+
```sh
27
20
docker-compose up
28
21
```
29
22
30
23
If Docker is running successfully, the API and DB server will be launched as shown in the following:
31
24
32
25
- API server: http://localhost:8000
26
+
- API Docs: http://localhost:8000/v1/docs
33
27
- DB server: http://localhost:3306
34
28
35
29
_Be careful, it won't work if the port is occupied by another application._
36
30
37
-
If you want to check docker is actually working, then you can check it with following command:
38
-
39
-
```bash
40
-
docker ps
41
-
```
42
-
43
-
If you want to go inside of docker container, then try to use following command:
44
-
45
-
```bash
46
-
docker-compose exec mysql bash
47
-
docker-compose exec api bash
48
-
```
49
-
50
-
For shutdown of the docker instance, please use following command:
51
-
52
-
```bash
53
-
docker-compose down
54
-
```
55
-
56
-
## Need a front-end app?
31
+
## Setup with the VS Code Dev Containers extension
57
32
58
-
If you need a front-end app for this server-side & DB server.
33
+
The above setup can be used for development, but you can also setup dev env with using the [VS Code Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
- Install VS code and the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
36
+
- Run the `Dev Containers: Open Folder in Container...` command from the Command Palette or quick actions Status bar item, and select the project folder.
37
+
-Wait until the building of the application is finished, then access the application url
63
38
64
39
---
65
40
@@ -69,29 +44,39 @@ You can clone the front-end template from:
69
44
70
45
If you're [VS Code](https://code.visualstudio.com/) user, you can easily setup Python code formatter (black) and linter (flake8) by simply installing the extensions.
71
46
72
-
Automatic formatting settings have already been defined here:
73
-
74
-
`.vscode/settings.json`
47
+
Automatic formatting settings have already been defined [`.vscode/settings.json`](./.vscode/settings.json).
If you are using the Dev Container, this configuration is already done in [the Dev Container settings](./.devcontainer/devcontainer.json), so you can skip it.
55
+
81
56
### How to check the DB tables in container
82
57
83
-
You can check the DB data by actually executing a query using the following command:
58
+
Use following command to go inside of docker container:
59
+
60
+
```sh
61
+
docker-compose exec mysql sh
62
+
```
63
+
64
+
Then use `mysql` command to execute a query:
84
65
85
-
```bash
86
-
docker-compose exec mysql bash
66
+
```sh
87
67
mysql -u root -p
88
68
mysql> USE fastapi_app;
89
69
mysql> SHOW TABLES;
70
+
mysql> SELECT * FROM user;
90
71
```
91
72
73
+
Your initial MySQL password is defined in `mysql/local.env`.
74
+
92
75
### How to add a library
93
76
94
-
You may want to add libraries such as requests, in which case follow these steps:
77
+
Python libraries used in this app are defined in `api/requirements.txt`.
78
+
79
+
Also you may want to add libraries such as requests, in which case follow these steps:
95
80
96
81
- Add the library to requirements.txt
97
82
@@ -103,23 +88,15 @@ requests==2.30.0
103
88
104
89
Then try a re-build and see.
105
90
106
-
```
91
+
```sh
92
+
docker-compose down
107
93
docker-compose build
108
94
docker-compose up
109
95
```
110
96
111
-
### Python library packages
112
-
113
-
Some of the Python packages used in this app are defined in `api/requirements.txt`.
114
-
Also you can add other packages there.
115
-
116
97
### Environment variable
117
98
118
-
Some of environment variable, like a database name and user is defined in `docker-compose.yml`.
119
-
You can customize it as you like.
120
-
121
-
If you will use docker, then please define your environment variable to `docker-compose.yml`.
122
-
However, you will NOT use docker, then please create `.env` file for your API server.
99
+
Some of environment variable, like a database name and user is defined in `docker-compose.yml` or `Dockerfile`.
123
100
124
101
### DB Migrations
125
102
@@ -130,10 +107,21 @@ The sample table definition has already been created with the name `create_user_
130
107
131
108
### Save the local DB changes as a dump file
132
109
133
-
```bash
110
+
If you need to share local DB changes with other developers, you can use `mysqldump` to create a backup and share it with them.
111
+
112
+
To create a `dump.sql', run the following command:
0 commit comments