# ai-web — node build, nginx serve.
FROM node:22-alpine AS build
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .

# Where the browser should send /ask. Empty - the default - means same-origin:
# Caddy routes /ask under ai.yokogawa.tech to ai-api, so no hostname is baked
# into the bundle at all. A tunnelled demo build overrides it:
#   --build-arg VITE_API_BASE=http://localhost:8001
# Vite inlines this at BUILD time, so a change needs a rebuild, not a restart.
ARG VITE_API_BASE=""
ENV VITE_API_BASE=$VITE_API_BASE

RUN npm run build

FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
