Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created July 17, 2018 22:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TooTallNate/d3c12f72d8c0d418bdfa78179e6ca9f4 to your computer and use it in GitHub Desktop.
Save TooTallNate/d3c12f72d8c0d418bdfa78179e6ca9f4 to your computer and use it in GitHub Desktop.
Node.js + Dockerfile
# This is the "base image" which contains Alpine Linux and Node.js v10.x.x preinstalled
FROM mhart/alpine-node:10
# Use the `NPM_TOKEN` build arg to create the `~/.npmrc` file
ARG NPM_TOKEN
RUN echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
# Set the working direcrory to `/usr/src`
WORKDIR /usr/src
# Copy the package.json and yarn.lock files into the iamge and run `yarn` to install dependencies
COPY package.json yarn.lock /usr/src/
RUN yarn
# Copy the remaining source files into the image
COPY . .
# At this point the build is "done". CMD specifies the command that will be executed for runtime
CMD ["node", "start.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment