# ---- Build stage ----
FROM node:22-alpine AS builder
WORKDIR /app
COPY server/package.json server/package-lock.json ./
RUN npm ci
COPY server/src ./src
COPY server/tsconfig.json ./
RUN npm run build

# ---- Runtime stage ----
FROM node:22-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY server/package.json server/package-lock.json ./
RUN npm ci --omit=dev
EXPOSE 3001
CMD ["node", "dist/index.js"]
