Last active
February 9, 2018 11:09
-
-
Save kennethlynne/e45390e2ed85a4f44b776cf89368532f to your computer and use it in GitHub Desktop.
Multi-stage docker for node apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ---- 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