-
-
Save yunusemre/3b20c80313c9f98bb8b99b1fcb59aaf8 to your computer and use it in GitHub Desktop.
Node.js Dockerfile Evolution
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
| FROM node:12 | |
| WORKDIR /usr/src/app | |
| COPY . . | |
| RUN npm install | |
| RUN npm run build | |
| CMD [ "npm", "start" ] |
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
| FROM node:12-alpine | |
| ENV NO_UPDATE_NOTIFIER true | |
| WORKDIR /usr/src/app | |
| COPY . . | |
| RUN npm install --no-optional | |
| RUN npm run build | |
| CMD [ "npm", "start" ] |
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
| FROM node:12-alpine | |
| ENV NO_UPDATE_NOTIFIER true | |
| WORKDIR /usr/src/app | |
| COPY package.json package-lock.json ./ | |
| RUN npm install --no-optional | |
| COPY . . | |
| RUN npm run build | |
| CMD [ "npm", "start" ] |
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
| # Stage 0 | |
| FROM node:12-alpine as builder | |
| ENV NO_UPDATE_NOTIFIER true | |
| COPY package.json package-lock.json ./ | |
| RUN npm install --no-optional | |
| COPY . . | |
| RUN npm run build | |
| # Stage 1 | |
| FROM node:12-alpine | |
| ENV NO_UPDATE_NOTIFIER true | |
| WORKDIR /usr/src/app | |
| COPY --from=builder dist ./dist | |
| COPY --from=builder public ./public | |
| COPY package.json package-lock.json ./ | |
| RUN npm install --no-bin-links --only=prod --no-optional --no-audit | |
| CMD [ "npm", "start" ] |
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
| # Stage 0 | |
| FROM node:12-alpine as builder | |
| ENV NO_UPDATE_NOTIFIER true | |
| COPY package.json package-lock.json ./ | |
| RUN npm install --no-optional | |
| COPY . . | |
| RUN npm run build | |
| # Stage 1 | |
| FROM node:12-alpine as installer | |
| ENV NO_UPDATE_NOTIFIER true | |
| COPY package.json package-lock.json ./ | |
| RUN npm install --no-bin-links --only=prod --no-optional --no-audit | |
| # Stage 2 | |
| FROM node:12-alpine | |
| ENV NO_UPDATE_NOTIFIER true | |
| WORKDIR /usr/src/app | |
| COPY --from=installer node_modules ./node_modules | |
| COPY --from=builder dist ./dist | |
| COPY --from=builder public ./public | |
| COPY package.json package-lock.json ./ | |
| CMD [ "npm", "start" ] |
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
| # Stage 0 | |
| FROM node:12-alpine as builder | |
| ENV NO_UPDATE_NOTIFIER true | |
| COPY package.json package-lock.json ./ | |
| RUN npm install --no-optional | |
| COPY . . | |
| RUN npm run build | |
| # Stage 1 | |
| FROM node:12-alpine as installer | |
| ENV NO_UPDATE_NOTIFIER true | |
| COPY package.json package-lock.json ./ | |
| RUN npm install --no-bin-links --only=prod --no-optional --no-audit && \ | |
| deluser --remove-home node && \ | |
| adduser --system --home /var/cache/bootapp --shell /sbin/nologin bootapp; | |
| # Stage 2 | |
| FROM node:12-alpine | |
| ENV NO_UPDATE_NOTIFIER true | |
| WORKDIR /usr/src/app | |
| COPY --from=installer /etc/passwd /etc/shadow /etc/ | |
| COPY --from=installer node_modules ./node_modules | |
| COPY --from=builder dist ./dist | |
| COPY --from=builder public ./public | |
| COPY package.json package-lock.json ./ | |
| USER bootapp | |
| CMD [ "npm", "start" ] |
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
| # Stage 0 | |
| FROM node:12-alpine as builder | |
| ENV NO_UPDATE_NOTIFIER true | |
| COPY package.json package-lock.json ./ | |
| RUN npm install --no-optional | |
| COPY . . | |
| RUN npm run build | |
| # Stage 1 | |
| FROM node:12-alpine as installer | |
| ENV NO_UPDATE_NOTIFIER true | |
| ENV TINI_VERSION v0.19.0 | |
| ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini | |
| COPY package.json package-lock.json ./ | |
| RUN chmod +x /tini && \ | |
| npm install --no-bin-links --only=prod --no-optional --no-audit && \ | |
| deluser --remove-home node && \ | |
| adduser --system --home /var/cache/bootapp --shell /sbin/nologin bootapp | |
| # Stage 2 | |
| FROM node:12-alpine | |
| ENV NO_UPDATE_NOTIFIER true | |
| WORKDIR /usr/src/app | |
| COPY --from=installer /tini /tini | |
| COPY --from=installer /etc/passwd /etc/shadow /etc/ | |
| COPY --from=installer node_modules ./node_modules | |
| COPY --from=builder dist ./dist | |
| COPY --from=builder public ./public | |
| COPY package.json package-lock.json ./ | |
| USER bootapp | |
| ENTRYPOINT ["/tini", "--"] | |
| CMD [ "node", "./dist/bin/www.js" ] |
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
| # Stage 0 | |
| FROM node:12-alpine as builder | |
| ENV NO_UPDATE_NOTIFIER true | |
| COPY package.json package-lock.json ./ | |
| RUN npm install --no-optional | |
| COPY . . | |
| RUN npm run build | |
| # Stage 1 | |
| FROM node:12-alpine as installer | |
| ENV NO_UPDATE_NOTIFIER true | |
| ENV TINI_VERSION v0.19.0 | |
| ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini | |
| COPY package.json package-lock.json ./ | |
| RUN chmod +x /tini && \ | |
| npm install --no-bin-links --only=prod --no-optional --no-audit && \ | |
| deluser --remove-home node && \ | |
| adduser --system --home /var/cache/bootapp --shell /sbin/nologin bootapp | |
| # Stage 2 | |
| FROM gcr.io/distroless/nodejs-debian10:12 | |
| ENV NO_UPDATE_NOTIFIER true | |
| WORKDIR /usr/src/app | |
| COPY --from=installer /tini /tini | |
| COPY --from=installer /etc/passwd /etc/shadow /etc/ | |
| COPY --from=installer node_modules ./node_modules | |
| COPY --from=builder dist ./dist | |
| COPY --from=builder public ./public | |
| COPY package.json package-lock.json ./ | |
| USER bootapp | |
| ENTRYPOINT ["/tini", "--"] | |
| CMD [ "/nodejs/bin/node", "./dist/bin/www.js" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment