Last active
March 8, 2018 13:10
-
-
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.
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
node_modules |
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
# 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