Skip to content

Instantly share code, notes, and snippets.

@joshuaquek
Last active December 24, 2018 07:24
Show Gist options
  • Save joshuaquek/5292050d1784c71601b63735a191f2f9 to your computer and use it in GitHub Desktop.
Save joshuaquek/5292050d1784c71601b63735a191f2f9 to your computer and use it in GitHub Desktop.
A sample Dockerfile to deploy NodeJS locally on your own desktop machine.
Summary: A sample Dockerfile and .dockerignore file to deploy NodeJS locally on your own desktop machine.
node_modules
npm-debug.log
# specify the node base image with your desired version node:<version>
FROM node:10-alpine
# Set the working directory to /app
WORKDIR /app
# Only run NPM Install if package.json changes (this allows node_modules to be cached)
COPY package.json /app/package.json
RUN cd /app; npm install
# Copy the current directory contents into the container at /app
COPY . /app
# Ports to expose to local machine
EXPOSE 8080 7501 9001
# Place the NPM script that you want to run over here:
RUN npm run staging
#!/bin/bash
docker build -t myapp-image .; docker run -it --rm --name myapp-instance myapp-image ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment