A simple Node.js application built with Express.js, Redis, and MongoDB, fully containerized using Docker and Docker Compose.
- 🛠 Express.js: Lightweight framework for building web applications.
- 🐋 Dockerized: Fully containerized with
docker-compose
. - 🗃 MongoDB: NoSQL database for data storage.
- 🚀 Redis: In-memory data store for caching.
- 🔄 Hot-Reload: Automatic reloading in development with
nodemon
- Node.js (if running locally)
- Docker
- Docker Compose
git clone https://github.com/abdorrahmani/nodejs-dockerized-app.git
cd nodejs-dockerized-app
Ensure the following environment variables are set in .env
:
# Application settings
APP_NAME=NodejsDockerizedApp
APP_PORT=3000
# Redis settings
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_USERNAME=default
REDIS_PASSWORD=redispassword
REDIS_DB=0
# MongoDB settings
MONGO_HOST=mongo
MONGO_PORT=27017
MONGO_USERNAME=mongouser
MONGO_PASSWORD=mongopassword
MONGO_DB=appdatabase
docker-compose up --build
Visit http://localhost:3000 in your browser.
npm install
npm run dev
npm start
nodejs-dockerized-app/
├── app.js # Main application logic
├── Dockerfile # Docker image configuration
├── docker-compose.yml # Docker Compose configuration
├── .env # Environment variables
├── .env.example # Example Environment variables
├── nodemon.json # Nodemon configuration
├── package.json # Node.js project metadata
└── README.md # Project documentation
Command | Description |
---|---|
npm start |
Run the app in production |
npm run dev |
Run the app in development |
- Node.js: Runtime for JavaScript.
- Express.js: Web framework.
- Redis: In-memory data structure store.
- MongoDB: NoSQL database.
- Docker: Containerization platform.
- Ensure
Docker Desktop
andWSL2
are properly configured if using Windows. - Check the logs of the containers for debugging:
docker logs <container_name>
Contributions are welcome! Please submit a pull request or open an issue if you find bugs or have suggestions.
Thanks to the developers of Node.js, Redis, MongoDB, and the Docker community for their awesome tools.