A production-ready multi-container application deployed on AWS EC2 with automated CI/CD pipeline. The application consists of a Node.js Todo API, MongoDB database, and Nginx reverse proxy, all orchestrated using Docker Compose.
This project is part of the DevOps Project Based Learning curriculum
- URL: http://mca.nikhilmishra.live
- API Endpoints:
GET /health
- Health check endpointGET /api/todos
- List all todosPOST /api/todos
- Create a new todoGET /api/todos/:id
- Get a specific todoPUT /api/todos/:id
- Update a todoDELETE /api/todos/:id
- Delete a todo
flowchart TB
Client([Client])-. HTTP Request .->Nginx
subgraph AWS EC2
Nginx[Nginx Reverse Proxy]
API[Node.js Todo API]
MongoDB[(MongoDB Database)]
Nginx-->API
API-->MongoDB
end
GH[GitHub Actions]-.CI/CD Pipeline.->API
- Control Node: 44.203.38.191 (Ubuntu)
- Target Node: 3.87.64.105 (Ubuntu)
- Domain: mca.nikhilmishra.live
multi-container-service/
βββ app/ # Node.js Todo API
β βββ src/ # Source code
β β βββ app.js # Express application setup
β β βββ index.js # Server entry point
β β βββ models/ # MongoDB models
β β βββ routes/ # API routes
β βββ test/ # Test files
β βββ Dockerfile # API container configuration
β βββ package.json # Node.js dependencies
βββ nginx/ # Nginx configuration
β βββ conf.d/ # Nginx server blocks
βββ ansible/ # Ansible playbooks
β βββ inventory/ # Host definitions
β βββ playbooks/ # Deployment playbooks
βββ .github/workflows/ # GitHub Actions CI/CD
βββ .env # Environment variables
βββ docker-compose.yml # Container orchestration
- Express.js framework
- MongoDB with Mongoose ODM
- RESTful endpoints
- Health check endpoint
- Error handling middleware
- Input validation
- Multi-container setup with Docker Compose
- Optimized Dockerfile with multi-stage builds
- Volume management for data persistence
- Container networking
- Environment-specific configurations
- Load balancing
- SSL/TLS termination (planned)
- Static file serving
- Proxy configuration
- Security headers
- Automated testing
- Docker image building
- Container registry publishing
- Automated deployment
- Health checks
$ curl http://mca.nikhilmishra.live/health
{"status":"ok","mongodb":"connected"}
$ curl -X POST -H "Content-Type: application/json" \
-d '{"title":"Test Todo","description":"Testing the API"}' \
http://mca.nikhilmishra.live/api/todos
{
"title": "Test Todo",
"description": "Testing the API",
"completed": false,
"_id": "67aafed247e49f9194b3e805",
"createdAt": "2025-02-11T10:20:08.462Z",
"updatedAt": "2025-02-11T10:20:08.462Z"
}
$ curl http://mca.nikhilmishra.live/api/todos
[
{
"_id": "67aafed247e49f9194b3e805",
"title": "Test Todo",
"description": "Testing the API",
"completed": false,
"createdAt": "2025-02-11T10:20:08.462Z",
"updatedAt": "2025-02-11T10:20:08.462Z"
}
]
- Docker and Docker Compose
- Node.js >= 14.0.0
- Git
- Ansible
-
Clone the repository
git clone https://github.com/kaalpanikh/multi-container-service.git cd multi-container-service
-
Install dependencies
cd app npm install
-
Start the development environment
docker-compose up -d
-
Access the API at http://localhost:3000
- Provision AWS EC2 instances for control and target nodes
- Configure security groups and networking
- Set up DNS records
- Push changes to the main branch
- GitHub Actions will:
- Run tests
- Build Docker images
- Push to container registry
- Deploy to target node
- Perform health checks
- Add HTTPS support with Let's Encrypt
- Implement container health checks
- Add monitoring with Prometheus/Grafana
- Set up log aggregation
- Implement blue-green deployment
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT
β CI/CD Pipeline: Working β API Endpoints: Working β MongoDB: Connected β Nginx: Configured