A production-ready MERN stack application containerized with Docker and automated using CI/CD.
This project demonstrates how to build and deploy a full-stack application using modern DevOps practices including Docker containers, reverse proxy architecture, and automated image builds.
Frontend
- React (Vite)
Backend
- Node.js
- Express.js
Database
- MongoDB
DevOps & Infrastructure
- Docker
- Docker Compose
- Nginx Reverse Proxy
- GitHub Actions CI/CD
Browser → Nginx Reverse Proxy → Frontend / Backend → MongoDB
Explanation:
- Nginx acts as the entry point
- React frontend is served as static files
- Node.js backend handles API requests
- MongoDB stores application data
- Docker containers isolate each service
mern-docker-production
backend
- Express API
- MongoDB connection
- Dockerfile
frontend
- React (Vite) application
- Dockerfile
nginx
- Reverse proxy configuration
.github/workflows
- CI/CD pipeline for Docker builds
docker-compose.yml
- Orchestrates all containers
Prerequisites
- Docker installed
- Docker Compose installed
Start the application
docker compose up --buildApplication URLs
Frontend http://localhost
Backend API http://localhost/api/users
This project runs four containers:
-
nginx
- Reverse proxy that routes requests
-
frontend
- React production build served by Nginx
-
backend
- Node.js Express API
-
mongo
- MongoDB database container
Automated using GitHub Actions.
Workflow steps:
- Push code to main branch
- GitHub Actions builds Docker images
- Images are pushed to Docker Hub
- Images are ready for deployment
Docker images:
dockerhubusername/mern-backend
dockerhubusername/mern-frontend
Backend (.env)
PORT=5000
MONGO_URI=mongodb://mongo:27017/mern-docker
Frontend (.env)
VITE_API_URL=/api
GET /api/users
Returns:
{
"message": "User API working"
}- Clone repository
git clone https://github.com/yourusername/mern-docker-production- Start containers
docker compose up-
Make code changes
-
Rebuild if needed
docker compose up --build- Kubernetes deployment
- Automated cloud deployment
- Authentication system
- Monitoring and logging
Eranga Madhushan
Computer Science Student
FullStack Developer
Open Source Contributor
