This project demonstrates how to Dockerize a full-stack MERN application, consisting of a MongoDB database, Express.js server, React.js frontend, and Node.js backend. The goal is to containerize each component of the application and ensure that it can be easily deployed, scaled, and managed.
-
MongoDB Database
- Container Name: mongodb
- Image: mongo:4.4.14
- Port: 27017
-
Express.js Server
- Container Name: express-server
- Image: node:14-alpine
- Port: 3000
-
React.js Frontend
- Container Name: react-frontend
- Image: node:14-alpine
- Port: 3001
-
Node.js Backend
- Container Name: node-backend
- Image: node:14-alpine
- Port: 4000
-
Clone the Repository: Clone this repository to your local machine using
git clone https://github.com/your-username/dockerized-mern-app.git
. -
Install Dependencies: Run
npm install
in the root directory to install all dependencies. -
Build Docker Images: Run
docker-compose build
to build the Docker images for each component. -
Start Docker Containers: Run
docker-compose up
to start the Docker containers for each component.
-
Start the Application: Run
docker-compose up
to start the Docker containers and the application. -
Access the Application: Open a web browser and navigate to
http://localhost:3000
to access the React.js frontend. -
Interact with the Application: Use the application as you would normally, and the data will be persisted in the MongoDB database.
- Docker: For containerization.
- Docker Compose: For managing and orchestrating the containers.
- MERN Stack: MongoDB, Express.js, React.js, and Node.js.
- Node.js: For the backend.
- React.js: For the frontend.
- MongoDB: For the database.
Contributions are welcome! If you find any issues or have suggestions for improvement, please create an issue or submit a pull request.