Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pawarvijay
Forked from ksmithut/.dockerignore
Created March 8, 2020 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawarvijay/13d756529bc78e890e96bf10901a9fe8 to your computer and use it in GitHub Desktop.
Save pawarvijay/13d756529bc78e890e96bf10901a9fe8 to your computer and use it in GitHub Desktop.
Node Docker Compose nodemon
node_modules

Reload node processes on file save in Docker

Run docker-compose up --build.

Make changes to index.js and see the server restart.

version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- ./:/usr/src/app
- /usr/src/app/node_modules # Remove this if you have pure JS dependencies
ports:
- "3000:3000"
FROM node:8-alpine
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install dependencies
COPY package.json .
RUN npm install
# Bundle app source
COPY . .
# Exports
EXPOSE 3000
CMD [ "npm", "run", "start.dev" ]
'use strict'
const express = require('express')
const { PORT = '3000' } = process.env
const app = express()
app.use((req, res, next) => {
res.send('Hello Jack')
})
app.listen(PORT)
{
"main": "index.js",
"scripts": {
"start": "node index",
"start.dev": "nodemon"
},
"dependencies": {
"express": "^4.16.2"
},
"devDependencies": {
"nodemon": "^1.14.12"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment