Sam Perrin TIL Blog

Docker - Sample Dockerfile for NodeJS app

September 02, 2019

FROM node:12

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies. A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

HEALTHCHECK --interval=5s  \
            --timeout=5s \
            CMD curl -f http://127.0.0.1:4000 || exit 1

EXPOSE 4000
CMD [ "node", "server.js" ]

Sam Perrin

Written by Sam Perrin who loves all things Automation related! You should follow him on Twitter