Skip to content

Instantly share code, notes, and snippets.

@eezing
Created September 27, 2018 18:20
Show Gist options
  • Save eezing/ace08a1d3030a41ce38735c7671ce898 to your computer and use it in GitHub Desktop.
Save eezing/ace08a1d3030a41ce38735c7671ce898 to your computer and use it in GitHub Desktop.

Docker for NodeJS

Dockerfile

FROM node:10.11-alpine

# Create app dir
RUN mkdir -p /usr/app
WORKDIR /usr/app

# Install npm packages (production only)
COPY package.json package-lock.json /usr/app/
RUN npm install --production > /dev/null 2>&1

# Copy all files
COPY . /usr/app/

# Expose port
EXPOSE 3000

# Env vars
ENV NODE_ENV production
ENV PORT 3000

# Define run command
CMD [ "node", "src/index.js" ]

# Run as non-root user
USER node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment