# BUILD
FROM node:20-alpine AS builder

WORKDIR /root/andreavillari

COPY package*.json ./
RUN npm install

# Copia del codice sorgente
COPY . .

# Impostazioni limite meoria Node.js
ENV NODE_OPTIONS:--max-old-space-size=768

# Esexuzione della build (verifica che nel package.json ci sia "build")
RUN npm run build

#PRODUCTION (standalone)

# --- STAGE 2 : Production (Serve file statici con Nginx)---
FROM nginx:alpine
COPY --from=builder /root/andreavillari/dist /usr/share/nginx/html

EXPOSE 80

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