A basic setup for a NodeJs app with mongoDb and docker-compose
Node Backend Template
This is a basic setup for a Node.js application with MongoDB and Docker Compose.
- Express.js server
- MongoDB integration
- Docker Compose configuration
Before running this project, make sure you have the following installed:
- Node.js
- Docker
- Docker Compose
- Clone this repository:
git clone https://github.com/your-username/node-backend-template.git
- Create your .env file:
cp .env.example .env
Update the .env
file with your MongoDB connection string:
MONGO_URI=mongodb://mongo:27017/test_db
If you are running the MongoDB server locally, you can use the following connection string:
MONGO_URI=mongodb://localhost:27017/test_db
- Build the containers:
cd node-backend-template
docker-compose -f docker-compose.yml -f docker-compose.mongo.yml build: for building both the node and mongo containers
docker-compose -f docker-compose.yml build: for building only the node container
- Start the containers:
docker-compose -f docker-compose.yml -f docker-compose.mongo.yml up: for starting both the node and mongo containers
docker-compose -f docker-compose.yml up: for starting only the node container
- Your Node.js application should now be running on
http://localhost:3001
and the MongoDB server should be running onhttp://localhost:27017
with a database namedtest_db
.
Contributions are welcome! Please feel free to submit a pull request.
This project is licensed under the ISC License.