# Multi-stage: build the Vite app here so CI produces an env-independent
# image (no .env needed at build time — the backend URL is injected at
# container start, see docker-entrypoint.d/30-frontend-config.sh).
FROM oven/bun:1 AS build
WORKDIR /app

COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile

COPY . .
RUN bun run build

FROM nginx:stable-alpine-perl
COPY --from=build /app/dist /usr/share/nginx/html
# nginx's entrypoint auto-runs *.sh in /docker-entrypoint.d/ on start.
# Unaffected by mounting a custom /etc/nginx/nginx.conf (separate path).
COPY docker-entrypoint.d/ /docker-entrypoint.d/
RUN chmod +x /docker-entrypoint.d/*.sh
EXPOSE 80
