Skip to content

Instantly share code, notes, and snippets.

@SaifRehman
Created April 9, 2020 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SaifRehman/f76f642e3fd5ebef4d86fb5220c4322a to your computer and use it in GitHub Desktop.
Save SaifRehman/f76f642e3fd5ebef4d86fb5220c4322a to your computer and use it in GitHub Desktop.
FROM node:12
# Install OS updates
RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get clean \
&& echo 'Finished installing dependencies'
# Install stack dependencies
WORKDIR /project/user-app
COPY ./package*.json ./
RUN npm install --production
# Install user-app dependencies
WORKDIR /project/user-app
COPY ./user-app/package*.json ./
RUN npm install --production
WORKDIR /project/user-app/node_modules
# Copy the dependencies into a slim Node docker image
FROM node:12-slim
RUN npm i -g webpack webpack-cli jest
# Install OS updates
RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get clean \
&& echo 'Finished installing dependencies'
# Copy the project
COPY --chown=node:node . /project
# Copy all dependencies
# COPY --chown=node:node --from=0 /project/node_modules /project/node_modules
COPY --chown=node:node --from=0 /project/user-app/node_modules /project/user-app/node_modules
WORKDIR /project
ENV NODE_PATH=/project/user-app/node_modules
ENV NODE_ENV production
ENV PORT 3000
RUN webpack-cli
USER node
EXPOSE 3000
RUN pwd
RUN ls
RUN ls dist/
CMD ["npm", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment