Created
February 7, 2018 11:47
-
-
Save praveenweb/acd27014e6d244c3194d3e9d7da04e17 to your computer and use it in GitHub Desktop.
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:carbon 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 src /app | |
# Build react/vue/angular bundle static files | |
# RUN npm run build | |
# --- Release with Alpine ---- | |
FROM node:8.9-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"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @praveenweb
Many thanks for this multi-stage Dockerfile!
Where would you suggest to add the node user, as this would run under root by default?
Many thanks!