Final Push
This commit is contained in:
parent
241a4a912c
commit
d9a1697bd1
220
README.md
220
README.md
@ -1,112 +1,192 @@
|
|||||||
# Docker Multi-Service Notes Application
|
# Docker Multi-Service Notes Application
|
||||||
|
|
||||||
## Project Overview
|
## 1. Introduction
|
||||||
|
|
||||||
This project is a multi-container web application deployed using Docker. It demonstrates how different services can work together using containerization.
|
This project is a multi-container web application deployed using Docker.
|
||||||
|
It demonstrates how multiple services such as frontend, backend,
|
||||||
|
database, and file storage can be containerized and orchestrated using
|
||||||
|
Docker Compose.
|
||||||
|
|
||||||
The application allows users to:
|
The system follows a microservices architecture where each service runs
|
||||||
|
independently and communicates through a Docker network.
|
||||||
|
|
||||||
- Add and delete notes
|
------------------------------------------------------------------------
|
||||||
- Upload files
|
|
||||||
- View and download uploaded files
|
|
||||||
|
|
||||||
---
|
## 2. Objectives
|
||||||
|
|
||||||
## Architecture
|
- Deploy a complete web application using Docker containers
|
||||||
|
- Use multiple services (frontend, backend, database)
|
||||||
|
- Enable communication between services
|
||||||
|
- Implement persistent storage using Docker volumes
|
||||||
|
- Provide scripts for managing the application lifecycle
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## 3. System Architecture
|
||||||
|
|
||||||
The application consists of the following services:
|
The application consists of the following services:
|
||||||
|
|
||||||
**Frontend (Nginx)**
|
### 3.1 Frontend (Nginx)
|
||||||
Serves static HTML, CSS, and JavaScript files. Accessible via browser.
|
|
||||||
|
|
||||||
**Backend (Node.js + Express)**
|
- Serves static files (HTML, CSS, JavaScript)
|
||||||
Handles API requests and manages notes and file uploads.
|
- Provides user interface for interacting with the system
|
||||||
|
|
||||||
**MongoDB**
|
### 3.2 Backend (Node.js + Express)
|
||||||
Stores notes data and uses a persistent Docker volume.
|
|
||||||
|
|
||||||
**Mongo Express**
|
- Handles API requests
|
||||||
Provides a web interface to view and manage database data.
|
- Implements business logic
|
||||||
|
- Manages notes and file uploads
|
||||||
|
|
||||||
---
|
### 3.3 MongoDB
|
||||||
|
|
||||||
## Technologies Used
|
- NoSQL database for storing notes
|
||||||
|
- Uses persistent storage
|
||||||
|
|
||||||
- Docker and Docker Compose
|
### 3.4 Mongo Express
|
||||||
- Node.js with Express
|
|
||||||
- MongoDB (NoSQL database)
|
|
||||||
- Nginx (web server)
|
|
||||||
- HTML, CSS, and JavaScript
|
|
||||||
|
|
||||||
---
|
- Web interface to view and manage database data
|
||||||
|
|
||||||
## Service Ports
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
| Service | Port |
|
## 4. Features
|
||||||
|---------------|------|
|
|
||||||
| Frontend | 8080 |
|
|
||||||
| Backend | 3000 |
|
|
||||||
| Mongo Express | 8081 |
|
|
||||||
|
|
||||||
---
|
- Create notes
|
||||||
|
- Delete notes
|
||||||
|
- Upload files
|
||||||
|
- List uploaded files
|
||||||
|
- Download files
|
||||||
|
- Persistent data storage
|
||||||
|
|
||||||
## Persistent Storage
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
The application uses Docker volumes to preserve data across container restarts:
|
## 5. Technologies Used
|
||||||
|
|
||||||
- `mongo-data` stores database records
|
- Docker
|
||||||
- `uploads/` stores user-uploaded files
|
- Docker Compose
|
||||||
|
- Node.js (Express)
|
||||||
|
- MongoDB
|
||||||
|
- Nginx
|
||||||
|
- HTML, CSS, JavaScript
|
||||||
|
|
||||||
Data is retained even after stopping the application.
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
---
|
## 6. Ports and Services
|
||||||
|
|
||||||
## How to Run
|
| Service | Port | Description |
|
||||||
|
|----------------|------|-----------------|
|
||||||
|
| Frontend | 8080 | Web interface |
|
||||||
|
| Backend | 3000 | API server |
|
||||||
|
| Mongo Express | 8081 | Database UI |
|
||||||
|
|
||||||
### 1. Prepare the application
|
------------------------------------------------------------------------
|
||||||
|
## 7. Database Credentials
|
||||||
|
|
||||||
```bash
|
The MongoDB database is configured with the following credentials:
|
||||||
./prepare-app.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Start the application
|
- **Username:** admin
|
||||||
|
- **Password:** pass
|
||||||
|
|
||||||
```bash
|
These credentials are used by Mongo Express to connect to the MongoDB service.
|
||||||
./start-app.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
Once running, open the following in your browser:
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
- Application: `http://147.232.204.210:8080`
|
## 8. Persistent Storage
|
||||||
- Database UI: `http://147.232.204.210/:8081`
|
|
||||||
|
|
||||||
### 3. Stop the application
|
The application uses Docker volumes:
|
||||||
|
|
||||||
```bash
|
- mongo-data → stores database data
|
||||||
./stop-app.sh
|
- uploads → stores uploaded files
|
||||||
```
|
|
||||||
|
|
||||||
### 4. Remove the application
|
These ensure that data is not lost when containers restart.
|
||||||
|
|
||||||
```bash
|
------------------------------------------------------------------------
|
||||||
./remove-app.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
## 9. Network Requirement (IMPORTANT)
|
||||||
|
|
||||||
## Application Workflow
|
⚠️ This application is hosted on a university virtual machine.
|
||||||
|
|
||||||
1. The user interacts with the frontend in a browser.
|
To access the application, you must:
|
||||||
2. The frontend sends API requests to the backend.
|
|
||||||
3. The backend processes the requests and communicates with MongoDB.
|
|
||||||
4. MongoDB stores or retrieves the relevant data.
|
|
||||||
5. Mongo Express provides a separate interface to inspect database content directly.
|
|
||||||
|
|
||||||
---
|
- Be connected to the **Tuke university network**, OR
|
||||||
|
- Use a **Tuke VPN connection**
|
||||||
|
|
||||||
|
Without VPN/network access, the application URLs may not be reachable.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## 10. Application Workflow
|
||||||
|
|
||||||
|
1. User accesses frontend via browser
|
||||||
|
2. Frontend sends requests to backend API
|
||||||
|
3. Backend processes requests
|
||||||
|
4. Backend interacts with MongoDB
|
||||||
|
5. MongoDB stores/retrieves data
|
||||||
|
6. Mongo Express allows database visualization
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## 11. Scripts
|
||||||
|
|
||||||
|
### 11.1 Prepare Application
|
||||||
|
|
||||||
|
./prepare-app.sh
|
||||||
|
|
||||||
|
- Builds Docker images
|
||||||
|
- Creates volumes and network
|
||||||
|
|
||||||
|
### 11.2 Start Application
|
||||||
|
|
||||||
|
./start-app.sh
|
||||||
|
|
||||||
|
- Starts all containers
|
||||||
|
- Application available at:
|
||||||
|
- http://147.232.204.210:8080
|
||||||
|
- http://147.232.204.210:8081
|
||||||
|
- http://147.232.204.210:3000
|
||||||
|
- http://147.232.204.210:3000/notes
|
||||||
|
|
||||||
|
|
||||||
|
### 11.3 Stop Application
|
||||||
|
|
||||||
|
./stop-app.sh
|
||||||
|
|
||||||
|
- Stops all containers
|
||||||
|
- Data remains intact
|
||||||
|
|
||||||
|
### 11.4 Remove Application
|
||||||
|
|
||||||
|
./remove-app.sh
|
||||||
|
|
||||||
|
- Removes containers, volumes, and images
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## 12. Docker Configuration
|
||||||
|
|
||||||
|
The application is configured using docker-compose.yml, where:
|
||||||
|
|
||||||
|
- Each service runs in its own container
|
||||||
|
- Services communicate using Docker networking
|
||||||
|
- Volumes are used for persistent storage
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## 13. Key Concepts Demonstrated
|
||||||
|
|
||||||
|
- Multi-container Docker architecture
|
||||||
|
- Service isolation and communication
|
||||||
|
- Persistent storage using volumes
|
||||||
|
- RESTful API design
|
||||||
|
- Static file serving
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
## 14. Conclusion
|
||||||
|
|
||||||
|
This project demonstrates how to deploy a scalable web application using
|
||||||
|
Docker containers. It highlights the importance of modular architecture,
|
||||||
|
persistent storage, and service communication.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- Create and delete notes
|
|
||||||
- Upload files
|
|
||||||
- View and download uploaded files
|
|
||||||
- Persistent storage via Docker volumes
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user