Skip to content

Instantly share code, notes, and snippets.

@kennethlynne
Last active February 9, 2018 11:09
Show Gist options
  • Select an option

  • Save kennethlynne/e45390e2ed85a4f44b776cf89368532f to your computer and use it in GitHub Desktop.

Select an option

Save kennethlynne/e45390e2ed85a4f44b776cf89368532f to your computer and use it in GitHub Desktop.
Multi-stage docker for node apps
# ---- Base image ----
FROM node:8.9.4 AS base
RUN JOBS=MAX npm set progress=false && npm config set depth 0
WORKDIR /workdir
COPY /package*.json .
COPY /.npmrc .
# ---- Build ----
FROM base AS build
ARG NPM_TOKEN
WORKDIR /workdir
COPY . .
RUN npm run build
RUN npm prune --production
# ---- Release ----
FROM node:8.9.4-slim AS release
WORKDIR /workdir
COPY --from=build /workdir/. /workdir/
EXPOSE 3000
CMD ["node", "index.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment