# ---- Build ----
FROM node:20-bookworm-slim AS build
WORKDIR /app

# Dùng pnpm theo lockfile có sẵn
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm i --frozen-lockfile

# Build
COPY . .
RUN pnpm build

# ---- Run (Nginx) ----
FROM nginx:1.27-alpine
# Dùng nginx.conf sẵn trong repo (nhớ để listen 3000)
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Static files
COPY --from=build /app/dist /usr/share/nginx/html

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