Skip to content

ashyT-Cloud/devops-node-mongo-redis-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevOps Assignment – Node.js, MongoDB, Redis with Docker Compose

Overview

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.

Architecture

Client → Node.js API → MongoDB
↘ Redis Cache

Services are containerized and managed using Docker Compose.

Services Used

  • Node.js – REST API service
  • MongoDB – Database for storing data
  • Redis – Caching layer
  • Docker – Containerization
  • Docker Compose – Multi-container orchestration

Project Structure

devops-assignment │ ├── app │ ├── server.js │ ├── package.json │ ├── Dockerfile ├── docker-compose.yml ├── .env └── README.md

Environment Variables

Defined in .env PORT=3000 MONGO_URI=mongodb://mongo:27017/devopsdb REDIS_HOST=redis

Create environment variables

cp .env.example .env

Running the Application

Clone the repository and run:

docker-compose up --build

This will start three containers:

  • Node.js Application
  • MongoDB
  • Redis

Access the Application

http://localhost:3001/data

(or replace localhost with your EC2 public IP)

API Endpoints

Store Data

POST /data

Example request: curl -X POST http://localhost:3001/data

-H "Content-Type: application/json" -d '{"name":"Ashish"}'

Retrieve Data

GET /data

curl http://localhost:3001/data

The API first checks Redis cache before retrieving data from MongoDB.

Features Implemented

  • Containerized Node.js application
  • Multi-container setup using Docker Compose
  • MongoDB persistent storage
  • Redis caching
  • Environment variable configuration
  • Service communication via Docker network

Author

Ashish Thakur

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors