Dockerfile 716 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # 1. For build React app
  2. FROM node:lts AS development
  3. # Set working directory
  4. WORKDIR /app
  5. #
  6. COPY package.json /app/package.json
  7. COPY package-lock.json /app/package-lock.json
  8. # Same as npm install
  9. RUN npm ci
  10. COPY . /app
  11. ENV CI=true
  12. ENV PORT=3000
  13. CMD [ "npm", "start" ]
  14. FROM development AS build
  15. RUN npm run build
  16. # 2. For Nginx setup
  17. FROM nginx:alpine
  18. # Copy config nginx
  19. COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf
  20. WORKDIR /usr/share/nginx/html
  21. # Remove default nginx static assets
  22. RUN rm -rf ./*
  23. # Copy static assets from builder stage
  24. COPY --from=build /app/build .
  25. # Containers run nginx with global directives and daemon off
  26. ENTRYPOINT ["nginx", "-g", "daemon off;"]