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
This project uses Docker Compose to manage multiple services such as a frontend, backend, and a database. The configuration is defined in the `docker-compose.yml` file, and environment variables can be stored in environment files for different environments (e.g., development, production).
4
+
5
+
## Prerequisites
6
+
7
+
Before you begin, ensure you have the following installed on your machine:
By using multiple Dockerfiles in Docker Compose, we can manage complex multi-container applications where each service has its own environment and build process.
35
+
36
+
1. Build and Start the Application
37
+
38
+
To build and run both the frontend and backend services, you can change your directory to the `./apps` directory and run:
39
+
40
+
```bash
41
+
docker-compose up --build
42
+
```
43
+
44
+
This will:
45
+
46
+
- Build the Docker images for all services using the specified Dockerfiles
47
+
- Start the containers and map the defined ports
48
+
49
+
2. Access the Application
50
+
51
+
Once running, you can access:
52
+
53
+
- The **frontend** at http://localhost:3000
54
+
- The **user service** at http://localhost:3001
55
+
- The **question service** at http://localhost:8080
56
+
57
+
3. Stopping Services
58
+
59
+
To stop the running services, run:
60
+
61
+
```bash
62
+
docker-compose down
63
+
```
64
+
65
+
This command will stop and remove the containers, networks, and volumes created by docker-compose up.
66
+
67
+
## Troubleshooting
68
+
69
+
**Common Issues**
70
+
71
+
- Port Conflicts: If you encounter port conflicts, ensure the host ports specified in docker-compose.yml (e.g., 3000:3000) are not in use by other applications.
72
+
- Environment Variables Not Loaded: Ensure the `.env` files are in the correct directories as found in the `docker-compose.yml` file.
73
+
74
+
**Logs**
75
+
76
+
You can view the logs for each service using the following command:
77
+
78
+
```bash
79
+
docker-compose logs
80
+
```
81
+
82
+
**Useful Commands**
83
+
84
+
Rebuild a specific service:
85
+
86
+
```bash
87
+
docker-compose build <service_name>
88
+
```
89
+
90
+
Start services in detached mode (run in the background):
91
+
92
+
```bash
93
+
docker-compose up -d
94
+
```
95
+
96
+
Remove all containers, networks, and volumes created by Docker Compose:
0 commit comments