Dockerfile.production 898 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. # Add a work directory
  8. WORKDIR /app
  9. # Cache and Install dependencies
  10. COPY ./app/package.json .
  11. # COPY package-lock.json .
  12. RUN npm install --production
  13. # Copy app files
  14. COPY ./app .
  15. # Build the app
  16. ENV REACT_APP_API_URL=${REACT_APP_API_URL}
  17. RUN npm run build
  18. # Bundle static assets with nginx
  19. FROM nginx:1.21.0-alpine as production
  20. ENV NODE_ENV production
  21. # Copy built assets from builder
  22. COPY --from=builder /app/build /usr/share/nginx/html
  23. # Add your nginx.conf
  24. COPY nginx.conf /etc/nginx/conf.d/default.conf
  25. # Expose port
  26. EXPOSE 80
  27. # Start nginx
  28. CMD ["nginx", "-g", "daemon off;"]