25 lines
623 B
Docker
25 lines
623 B
Docker
# Etapa 1: Compilación de la aplicación de React + Vite
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Recibir la variable de entorno VITE_API_URL en tiempo de construcción (build arg)
|
|
ARG VITE_API_URL
|
|
ENV VITE_API_URL=$VITE_API_URL
|
|
|
|
# Copiar los manifiestos de dependencias e instalarlas
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
# Copiar el código fuente y compilar el proyecto
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Etapa 2: Servir los archivos estáticos usando Nginx
|
|
FROM nginx:alpine
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|