Dockerfile.production 823 B

1234567891011121314151617181920212223242526272829
  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. ENV NODE_ENV production
  6. # Add a work directory
  7. WORKDIR /app
  8. # Cache and Install dependencies
  9. COPY package.json .
  10. # COPY package-lock.json .
  11. RUN npm install --production
  12. # Copy app files
  13. COPY . .
  14. # Build the app
  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;"]