Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 1.15 KB

README.md

File metadata and controls

33 lines (20 loc) · 1.15 KB

Express app with nodemon development server

Uses nodemon to listen for server file changes, and restart the express server.

Prerequisites

  • Install Docker
  • Install Docker Compose

Setup

Run docker-compose build . - it will

  • copy package.json into the container
  • copy nodemon.json into the container
  • install all production dependencies from the package.json
  • copy contents of server/ to the container
  • expose port 4000 to the host
  • instruct the container to execute npm start on start up.

Inside the container, express will run on port 80.

Start

Run docker-compose up -d to create and start the container. You can now visit localhost:4000 and see the app running.

Start crash?

The docker-compose is setup to mount the node_modules, so it can crap the nodemon dependency, and run it. Therefor if you haven't run npm install locally in your folder, it will break. I'm trying to see if there can be a better solution for that, so there is no need to run npm install manually.

Watch changes

To watch the console.log from index.js when nodemon executes, then you can run the command docker logs -f <CONTAINER_ID>