This project demonstrates containerizing a Node.js application and orchestrating multiple services using Docker Compose. The application interacts with MongoDB for persistent storage and Redis for caching.
Client → Node.js API → MongoDB
↘ Redis Cache
Services are containerized and managed using Docker Compose.
- Node.js – REST API service
- MongoDB – Database for storing data
- Redis – Caching layer
- Docker – Containerization
- Docker Compose – Multi-container orchestration
devops-assignment │ ├── app │ ├── server.js │ ├── package.json │ ├── Dockerfile ├── docker-compose.yml ├── .env └── README.md
Defined in .env
PORT=3000
MONGO_URI=mongodb://mongo:27017/devopsdb
REDIS_HOST=redis
cp .env.example .env
Clone the repository and run:
docker-compose up --build
This will start three containers:
- Node.js Application
- MongoDB
- Redis
(or replace localhost with your EC2 public IP)
POST /data
Example request: curl -X POST http://localhost:3001/data
-H "Content-Type: application/json" -d '{"name":"Ashish"}'
GET /data
curl http://localhost:3001/data
The API first checks Redis cache before retrieving data from MongoDB.
- Containerized Node.js application
- Multi-container setup using Docker Compose
- MongoDB persistent storage
- Redis caching
- Environment variable configuration
- Service communication via Docker network
Ashish Thakur