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: docs/en/docker_compose_documentation_en.md
+62-30Lines changed: 62 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
-
# Docker Compose for the Project
1
+
# Docker Compose of the Project
2
2
3
3
## How the `docker-compose.yaml` Works
4
4
5
-
The file [`docker/docker-compose.yaml`](../../docker/docker-compose.yaml) is responsible for orchestrating the execution of the **MySQL database** and the **FastAPI API** using Docker Compose.
6
-
It defines how services interact, their dependencies, and how data is persisted.
5
+
The file [`docker/docker-compose.yaml`](../../docker/docker-compose.yaml) is responsible for orchestrating the execution of **MySQL databases** (production and test) and the **FastAPI API** using Docker Compose.
6
+
It defines how the services interact, their dependencies, and how data is persisted.
7
7
8
8
---
9
9
10
-
### Step by step of what it does:
10
+
### Step by Step of What It Does:
11
11
12
-
1.**MySQL Service**
12
+
1.**MySQL Service (Production)**
13
13
```yaml
14
14
mysql:
15
15
build:
@@ -26,13 +26,36 @@ It defines how services interact, their dependencies, and how data is persisted.
26
26
- "3307:3306"
27
27
volumes:
28
28
- mysql_data:/var/lib/mysql
29
-
```
30
-
- Builds a custom MySQL 8 image with schema preloaded.
31
-
- Creates database `todolist` with user `app`.
29
+
```
30
+
- Builds a custom MySQL 8 image with the schema already loaded.
31
+
- Creates the database `todolist` with user `app`.
32
32
- Exposes port **3307** on the host.
33
-
- Uses a **named volume** (`mysql_data`) to persist data.
33
+
- Uses a **named volume** (`mysql_data`) for data persistence.
34
34
35
-
2. **API Service**
35
+
2. **MySQL Service (Tests)**
36
+
```yaml
37
+
mysql-test:
38
+
build:
39
+
context: ..
40
+
dockerfile: docker/MySQL/dockerfile
41
+
image: todolist-mysql
42
+
container_name: todolist-mysql-test
43
+
environment:
44
+
MYSQL_ROOT_PASSWORD: root_pass
45
+
MYSQL_DATABASE: todolist
46
+
MYSQL_USER: app_test
47
+
MYSQL_PASSWORD: app_pass_test
48
+
ports:
49
+
- "3308:3306"
50
+
volumes:
51
+
- mysql_data_test:/var/lib/mysql
52
+
```
53
+
- Creates a separate container for **automated testing**.
54
+
- Independent `todolist` database with user `app_test`.
55
+
- Uses port **3308** to avoid conflicts with the production database.
56
+
- Separate volume (`mysql_data_test`) to keep test data isolated from production.
57
+
58
+
3. **API Service**
36
59
```yaml
37
60
api:
38
61
build:
@@ -46,38 +69,39 @@ It defines how services interact, their dependencies, and how data is persisted.
0 commit comments