Skip to content

Instantly share code, notes, and snippets.

@sandiprb
Created June 17, 2020 20:29
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 sandiprb/399285f9beb0d1b3df445979e9abc1f8 to your computer and use it in GitHub Desktop.
Save sandiprb/399285f9beb0d1b3df445979e9abc1f8 to your computer and use it in GitHub Desktop.
Deploy React / Vue / Front-end node projects with nginx Docker image
# Use a lighter version of Node as a parent image
FROM node:10 as project-build
# Set the working directory to /frontend
WORKDIR /project
COPY package*.json /project/
RUN npm install
COPY . /project/
RUN npm run build # replace this if your project uses a diffrent build command
FROM nginx:alpine
COPY --from=project-build /project/build/ /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment