# --- Etapa 1: Build ---
FROM node:20-alpine AS build
WORKDIR /app

# Copia solo dependencias primero para cachear
COPY Frontend/package.json Frontend/package-lock.json ./
RUN npm install --frozen-lockfile --no-audit

# Copia el resto del código
COPY Frontend/. .

# Construye la aplicación
RUN npm run build

# --- Etapa 2: Serve ---
FROM nginx:stable-alpine
COPY Frontend/nginx.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html

RUN rm -f index.html
COPY --from=build /app/dist .

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]