Last active
June 14, 2019 19:35
-
-
Save sandeep540/acd30fd20f168df481222e86eb0acefe to your computer and use it in GitHub Desktop.
Dockerfile multistage node
This file contains 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 Node ---- | |
FROM node:11.10 AS base | |
# Create app directory | |
WORKDIR /app | |
# ---- Dependencies ---- | |
FROM base AS dependencies | |
# A wildcard is used to ensure both package.json AND package-lock.json are copied | |
COPY package*.json ./ | |
# install app dependencies including 'devDependencies' | |
RUN npm install | |
# ---- Copy Files/Build ---- | |
FROM dependencies AS build | |
WORKDIR /app | |
COPY . . | |
# Build react/vue/angular bundle static files | |
# RUN npm run build | |
# --- Release with Alpine ---- | |
FROM node:11.10.0-alpine AS release | |
# Create app directory | |
WORKDIR /app | |
# optional | |
# RUN npm -g install serve | |
COPY --from=dependencies /app/package.json ./ | |
# Install app dependencies | |
RUN npm install --only=production | |
COPY --from=build /app ./ | |
#CMD ["serve", "-s", "dist", "-p", "8080"] | |
CMD ["node", "server.js"] | |
# docker build -t image_name . | |
# docker tag a69905a3f40c sandeep540/node-mongo | |
# docker push sandeep540/node-mongo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment