[object Object]

Node Docker Basic Template

All Contributors

Technologies Used

Node.js, Express.js, Docker, Redis, MongoDB, Nginx

Development Setup

Before setting up the project make sure you have an IDE.

  1. Fork the repository. (Click Top Right in this Page)

  2. Clone the repository which you have forked.

https://github.com/<YOUR_GITHUB_USERNAME>/node-docker.git
  1. Go into the directory containing the project.
cd node-docker
  1. Make sure you have Node.js Installed and run the below command. This command will spin up the application with required containers from docker-compose.yml & docker-compose.dev.yml files.
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build
  1. Run below command to get logs of the Application
docker logs <CONTAINER_ID>/<CONTAINER_NAME> -f
  1. Go to localhost:3000 to verify the running Application

Some Useful Commands

  1. To stop the application without removing volumes, run the below command.
docker-compose -f docker-compose.yml -f docker-compose.dev.yml down
  1. To spin up the application again after executing above command, run the below command
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d -V
  1. To stop the application and also remove the volumes, run the below command.
docker-compose -f docker-compose.yml -f docker-compose.dev.yml down -v
  1. If any new npm package is added, run the below command.
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build -V
  1. To scale the express application, run the below command by specifing the number.
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --scale node-app=<number>