Dockerfile.production 840 B

12345678910111213141516171819202122232425262728293031
  1. # Esta imagen es multi-stage, es decir,
  2. # se buildea en un contenedor transitorio, y luego se hace otro contenedor que sirva la app.
  3. # Esto para que la imagen sea más liviana y no incluya nada más que el build de producción y nginx
  4. FROM node:14-alpine AS builder
  5. ARG REACT_APP_API_URL
  6. ENV NODE_ENV production
  7. # Copy app files
  8. COPY . /app
  9. # Add a work directory
  10. WORKDIR /app
  11. # COPY package-lock.json .
  12. RUN npm install --production
  13. # Build the app
  14. ENV REACT_APP_API_URL=${REACT_APP_API_URL}
  15. RUN npm run build
  16. # Bundle static assets with nginx
  17. FROM nginx:1.21.0-alpine as production
  18. ENV NODE_ENV production
  19. # Copy built assets from builder
  20. COPY --from=builder /app/build /usr/share/nginx/html
  21. # Add your nginx.conf
  22. COPY nginx.conf /etc/nginx/conf.d/default.conf
  23. # Expose port
  24. EXPOSE 80
  25. # Start nginx
  26. CMD ["nginx", "-g", "daemon off;"]