Skip to content

Instantly share code, notes, and snippets.

@deepakprasanna
Last active March 8, 2018 13:10
Show Gist options
  • Save deepakprasanna/53e123ee9de31ee7b2849f871588a87e to your computer and use it in GitHub Desktop.
Save deepakprasanna/53e123ee9de31ee7b2849f871588a87e to your computer and use it in GitHub Desktop.
Dockerfile for create-react-app using multistage builds. Forgetting the .dockerignore file can make your build process painfully slow.
# For buidling
FROM node:9.6.1 as builder
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json yarn.lock /usr/src/app/
RUN npm install yarn
RUN yarn install
COPY . /usr/src/app
RUN yarn build
# For production
FROM nginx:1.13.9-alpine
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# Steps to run.
# docker build -t app-production .
# docker run -it -p 80:80 --rm app-production
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment