# ---- Stage 1: build del sito statico con Node.js ----
FROM docker.io/library/node:22-alpine AS build
WORKDIR /app

COPY package.json ./
RUN npm install --no-audit --no-fund

COPY astro.config.mjs tsconfig.json ./
COPY src ./src
COPY public ./public

RUN npx astro build

# ---- Stage 2: serve con nginx ----
FROM docker.io/library/nginx:1.27-alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
