Skip to content

Instantly share code, notes, and snippets.

@taras-d
Last active April 25, 2018 13:15
Show Gist options
  • Save taras-d/6a1c53e3b6e8b0b5add007ee7dfda109 to your computer and use it in GitHub Desktop.
Save taras-d/6a1c53e3b6e8b0b5add007ee7dfda109 to your computer and use it in GitHub Desktop.
Dockerfile example for Node

Dockerfile example for Node

# Step 1
# Use Node 8 as base image
FROM node:8

# Step 2
# Create app directory (next steps will be executed relative to this directory)
WORKDIR /usr/src/app

# Step 3
# Copy source (skip files/folders listed in .dockerignore)
COPY . .

# Step 4
# Install node modules
RUN npm install

# Step 5
# Define available ports for host OS
EXPOSE 9500

# Step 6
# Start application
CMD ["npm", "start"]



# Usage:
# (1) Build image - docker build -t my-node-app .
# (2) Run image   - docker run -p 9600:9500 -d my-node-app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment