# Frontend (TanStack Start SSR) for self-hosted Docker deploy.
# On Liara this folder is a Node buildpack and this Dockerfile is ignored;
# it's only used by the VPS docker-compose.
FROM node:22-slim AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
# "/" -> API_BASE becomes "" (relative), so the browser calls /api on the same
# origin and nginx proxies it to the backend. Avoids the Liara prod fallback URL.
ENV VITE_API_BASE="/"
RUN npm run build

FROM node:22-slim AS run
WORKDIR /app
ENV NODE_ENV=production \
    PORT=3000
COPY --from=build /app/.output ./.output
EXPOSE 3000
CMD ["node", ".output/server/index.mjs"]
