Skip to content

Instantly share code, notes, and snippets.

@paulonteri
Created May 7, 2020 11:13
Show Gist options
  • Save paulonteri/3a4468ed69f240db4508341bafd3a453 to your computer and use it in GitHub Desktop.
Save paulonteri/3a4468ed69f240db4508341bafd3a453 to your computer and use it in GitHub Desktop.
React Dockerfile
# REACT PROJECT SETUP
# this Dockerfile starts with a Node 12.2.0 parent image
FROM node:12.2.0 AS build
# Set the working directory to /code
WORKDIR /code
# Copies package.json and package-lock.json to Docker environment
COPY package*.json ./
COPY yarn.lock ./
COPY . .
RUN yarn
RUN yarn build
# NGINX SETUP
# production environment
FROM nginx:1.16.0-alpine
# copy from the image above(build)
COPY --from=build /code/build /usr/share/nginx/html
# replace nginx config with custom one
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
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