Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dennisschneider/f0a68c2081ab281865661cfa16e38592 to your computer and use it in GitHub Desktop.
Save dennisschneider/f0a68c2081ab281865661cfa16e38592 to your computer and use it in GitHub Desktop.
Dockerfile to deploy a create-react-app project to production
### STAGE 1: Build ###
FROM node:9.11.1 as build
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
RUN npm install --silent
RUN npm install react-scripts -g --silent
COPY . /usr/src/app
RUN npm run build
### STAGE 2: Production Environment ###
FROM nginx:1.13.12-alpine
COPY --from=build /usr/src/app/build /usr/share/nginx/html
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