# Multi-stage Dockerfile for NASHTAWALA Full-Stack Restaurant App
FROM node:22-alpine AS builder

WORKDIR /app

# Install dependencies
COPY package*.json ./
RUN npm ci

# Copy all source files
COPY . .

# Build the client application (Vite production bundle into dist/)
RUN npm run build

# Production runner stage
FROM node:22-alpine AS runner

WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000

# Copy node_modules and built assets
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/server.ts ./
COPY --from=builder /app/serverDelivery.ts ./
COPY --from=builder /app/serverPrinter.ts ./
COPY --from=builder /app/serverNutrition.ts ./

EXPOSE 3000

CMD ["npx", "tsx", "server.ts"]
