Update README.md

This commit is contained in:
Joblin John Jeya Rockas 2026-04-27 22:34:15 +00:00
parent 7dbe0d81fa
commit b9ec34979b

254
README.md
View File

@ -1,192 +1,166 @@
# Docker Multi-Service Notes Application
# Notes Application - Docker & Kubernetes Deployment
## 1. Introduction
## Overview
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 system follows a microservices architecture where each service runs
independently and communicates through a Docker network.
------------------------------------------------------------------------
## 2. Objectives
- 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:
### 3.1 Frontend (Nginx)
- Serves static files (HTML, CSS, JavaScript)
- Provides user interface for interacting with the system
### 3.2 Backend (Node.js + Express)
- Handles API requests
- Implements business logic
- Manages notes and file uploads
### 3.3 MongoDB
- NoSQL database for storing notes
- Uses persistent storage
### 3.4 Mongo Express
- Web interface to view and manage database data
------------------------------------------------------------------------
## 4. Features
This project is a Notes Application deployed using Docker and Kubernetes (MicroK8s).
The application allows users to:
- Create notes
- Delete notes
- Upload files
- List uploaded files
- Download files
- Persistent data storage
------------------------------------------------------------------------
It follows a 3-tier architecture:
## 5. Technologies Used
- Frontend (Nginx)
- Backend (Node.js)
- Database (MongoDB)
- Docker
- Docker Compose
- Node.js (Express)
- MongoDB
- Nginx
- HTML, CSS, JavaScript
## Architecture
------------------------------------------------------------------------
```
User -> Frontend (Nginx) -> Backend (Node.js) -> MongoDB
```
## 6. Ports and Services
## Containers
| Service | Port | Description |
|----------------|------|-----------------|
| Frontend | 8080 | Web interface |
| Backend | 3000 | API server |
| Mongo Express | 8081 | Database UI |
### Frontend
------------------------------------------------------------------------
## 7. Database Credentials
- Image: `nginx:alpine`
- Role: Serves static UI
- Port: `80`
The MongoDB database is configured with the following credentials:
### Backend
- **Username:** admin
- **Password:** pass
- Image: `node:18`
- Role: API server (handles notes & files)
- Port: `3000`
These credentials are used by Mongo Express to connect to the MongoDB service.
### Database
------------------------------------------------------------------------
- Image: `mongo:6.0`
- Role: Stores notes and file data
- Port: `27017`
## 8. Persistent Storage
## Kubernetes Resources
The application uses Docker volumes:
- Namespace: `z2`
- Deployments:
- `frontend`
- `backend`
- StatefulSet:
- `mongo`
- Services:
- `frontend` (NodePort -> 30007)
- `backend` (ClusterIP)
- `mongo` (Headless Service)
- mongo-data → stores database data
- uploads → stores uploaded files
## Storage
These ensure that data is not lost when containers restart.
- Persistent Volume Claim: `mongo-storage`
- Size: `1Gi`
- Mount path: `/data/db`
- Purpose: Store MongoDB data persistently
------------------------------------------------------------------------
## Setup Instructions
## 9. Network Requirement (IMPORTANT)
⚠️ This application is hosted on a university virtual machine.
To access the application, you must:
- 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
### 1. Prepare Application
```bash
./prepare-app.sh
```
- Builds Docker images
- Creates volumes and network
- Loads them into MicroK8s
### 11.2 Start Application
### 2. Start Application
```bash
./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
- Deploys Kubernetes resources
- Starts all services
### 3. Stop Application
### 11.3 Stop Application
```bash
./stop-app.sh
```
- Stops all containers
- Data remains intact
- Stops running pods
- Keeps configuration
### 11.4 Remove Application
### 4. Delete Application
./remove-app.sh
```bash
microk8s kubectl delete all --all -n z2
microk8s kubectl delete pvc --all -n z2
```
- Removes containers, volumes, and images
- Removes everything including database
------------------------------------------------------------------------
## Access Application
## 12. Docker Configuration
Open in browser:
The application is configured using docker-compose.yml, where:
```
http://<server-ip>:30007
```
- Each service runs in its own container
- Services communicate using Docker networking
- Volumes are used for persistent storage
Example:
------------------------------------------------------------------------
```
http://147.232.204.210:30007
```
## 13. Key Concepts Demonstrated
## Useful Commands
- Multi-container Docker architecture
- Service isolation and communication
- Persistent storage using volumes
- RESTful API design
- Static file serving
Check pods:
------------------------------------------------------------------------
```bash
microk8s kubectl get pods -n z2
```
## 14. Conclusion
Check services:
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.
```bash
microk8s kubectl get svc -n z2
```
------------------------------------------------------------------------
View logs:
```bash
microk8s kubectl logs <pod-name> -n z2
```
## Common Issues
### Mongo Crash (version error)
Fix:
```bash
microk8s kubectl delete pvc --all -n z2
```
### Frontend shows "Welcome to nginx"
Fix:
- Ensure `index.html` is copied in Dockerfile
- Rebuild using:
```bash
./prepare-app.sh
```
## Honesty Statement
This project was developed with the assistance of AI tools (such as ChatGPT) for:
- Debugging errors
- Understanding Kubernetes concepts
- Identifying fixes for deployment issues
All configurations, testing, and final implementation were completed independently, and the AI was used strictly as a learning aid.