Last active
November 19, 2022 17:19
-
-
Save ZealousMacwan/74717dfa4104f0ce53d595b3c2e1d5cb to your computer and use it in GitHub Desktop.
React Dockerfile for development and production
This file contains hidden or 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
#development build | |
FROM node:18.12.1-alpine as development | |
ENV NODE_ENV development | |
WORKDIR /react-app | |
COPY package*.json . | |
#RUN yarn config set "strict-ssl" false -g | |
RUN yarn config set registry https://registry.npmjs.org | |
RUN yarn install | |
COPY . . | |
EXPOSE 3000 | |
CMD [ "yarn", "start" ] | |
#production build | |
FROM node:18.12.1-alpine as production_builder | |
ENV NODE_ENV production | |
WORKDIR /react-app | |
COPY package*.json . | |
#RUN yarn config set "strict-ssl" false -g | |
RUN yarn config set registry https://registry.npmjs.org | |
#--prodcution overrides the NODE_ENV | |
RUN yarn install --production | |
COPY . . | |
RUN yarn build | |
#production image | |
FROM nginx:1.22.1-alpine as production | |
ENV NODE_ENV production | |
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf | |
COPY --from=production_builder /react-app/build /usr/share/nginx/html | |
# Expose port | |
EXPOSE 80 | |
# Start nginx | |
CMD ["nginx", "-g", "daemon off;"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment