# Boojee Cafe - table-based dine-in ordering SPA (Vite + React), served by
# nginx as static files. Mirrors aiw-voice-app/Dockerfile.
#
# Build args:
#   VITE_MODE  "production" (default) or "staging" - Vite picks .env.<mode>
#              (VITE_CAFE_BACKEND_URL / VITE_CAFE_WIDGET_TOKEN / _URL).
#
# The cafe widget bundle (aiw-cafe-widget.js) is vendored in public/ so it
# ships same-origin at /aiw-cafe-widget.js - no second service / subdomain.
# Refresh it with `npm run sync:widget` after rebuilding the widget.

FROM node:20-alpine AS builder
WORKDIR /app

COPY package*.json ./
RUN npm ci

COPY . .

ARG VITE_MODE=production
RUN npm run build -- --mode "$VITE_MODE"

# ---- Runtime: nginx serving the static bundle ----
FROM nginx:alpine
WORKDIR /usr/share/nginx/html

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist ./

EXPOSE 80
