https://github.com/abdorrahmani/nodejs-dockerized-app
Node.js+Express.js+Redis+MongoDB+Docker
https://github.com/abdorrahmani/nodejs-dockerized-app
anophel docker docker-compose docker-image dockerfile expressjs mongodb node nodejs redis
Last synced: 4 months ago
JSON representation
Node.js+Express.js+Redis+MongoDB+Docker
- Host: GitHub
- URL: https://github.com/abdorrahmani/nodejs-dockerized-app
- Owner: abdorrahmani
- Created: 2025-01-11T06:43:31.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-12T10:30:46.000Z (about 1 year ago)
- Last Synced: 2025-01-12T10:31:16.212Z (about 1 year ago)
- Topics: anophel, docker, docker-compose, docker-image, dockerfile, expressjs, mongodb, node, nodejs, redis
- Language: JavaScript
- Homepage: https://anophel.com
- Size: 14.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node.js Dockerized App
[](https://nodejs.org/)
[](https://expressjs.com/)
[](https://www.docker.com/)
[](https://redis.io/)
[](https://www.mongodb.com/)
[](https://anophel.com)
[]()
A simple Node.js application built with Express.js, Redis, and MongoDB, fully containerized using Docker and Docker Compose.
---
## Features
- 🛠 **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`
---
## Prerequisites
- [Node.js](https://nodejs.org/) (if running locally)
- [Docker](https://www.docker.com/)
- [Docker Compose](https://docs.docker.com/compose/)
---
## Getting Started
### 1. Clone the Repository
```bash
git clone https://github.com/abdorrahmani/nodejs-dockerized-app.git
cd nodejs-dockerized-app
```
### 2. Environment Variables
Ensure the following environment variables are set in `.env`:
```yaml
# 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
```
### 3. Run the App
#### Using Docker Compose
```bash
docker-compose up --build
```
#### Access the App
Visit [http://localhost:3000](http://localhost:3000) in your browser.
### 4. Run Locally (Without Docker)
#### Install Dependencies
```bash
npm install
```
#### Development Mode
```bash
npm run dev
```
#### Production Mode
```bash
npm start
```
---
## File Structure
```plaintext
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
```
---
## Scripts
| Command | Description |
|---------------|------------------------------|
| `npm start` | Run the app in production |
| `npm run dev` | Run the app in development |
---
## Technologies Used
- **Node.js**: Runtime for JavaScript.
- **Express.js**: Web framework.
- **Redis**: In-memory data structure store.
- **MongoDB**: NoSQL database.
- **Docker**: Containerization platform.
---
## Troubleshooting
- Ensure `Docker Desktop` and `WSL2` are properly configured if using Windows.
- Check the logs of the containers for debugging:
```bash
docker logs
```
---
## Contributing
Contributions are welcome! Please submit a pull request or open an issue if you find bugs or have suggestions.
---
## Acknowledgements
Thanks to the developers of [Node.js](https://nodejs.org/), [Redis](https://redis.io/), [MongoDB](https://www.mongodb.com/), and the [Docker](https://www.docker.com/) community for their awesome tools.