Skip to content

Instantly share code, notes, and snippets.

@ironheart122
Created March 1, 2019 05:20
Show Gist options
  • Save ironheart122/45c01d988c5d8dd5862baf7374f133a7 to your computer and use it in GitHub Desktop.
Save ironheart122/45c01d988c5d8dd5862baf7374f133a7 to your computer and use it in GitHub Desktop.
Dockerfile for deploying a React app (created via CRA) in production
# Stage 1 - build environment
FROM node:8.15-alpine as builder
WORKDIR /usr/src/app/
COPY . ./
RUN npm install --production
RUN npm run build
# Stage 2- production environment
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /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