# Multi-stage build for the CurrenciCombo portal (Vite + React). # # Context MUST be the repo root so the vite build can see src/, public/, # index.html, etc.: # # docker build -t currencicombo/portal:local . # # VITE_ORCHESTRATOR_URL is baked at build time (Vite inlines env vars # prefixed with VITE_). In a sandbox compose, set it to whatever URL # the browser uses to reach the orchestrator — typically # http://localhost:8080 if the orchestrator's port is published on the # host. When unset, the portal runs in its built-in demo-fallback mode # (see src/services/orchestrator.ts). # ------- build stage ------- FROM node:20-alpine AS build WORKDIR /app ARG VITE_ORCHESTRATOR_URL="" ENV VITE_ORCHESTRATOR_URL=${VITE_ORCHESTRATOR_URL} COPY package.json package-lock.json ./ # vite 7 ships @rolldown/binding-* as platform-matched optional deps, # so we MUST include optional deps (skipping them breaks `vite build` # with "Cannot find native binding"). `fsevents` is also optional but # darwin-only; on linux npm 10 trips EBADPLATFORM on the lockfile # entry even though the runtime would never load it. `--force` downgrades # that EBADPLATFORM to a warning while still installing the rolldown # binding for the current platform. RUN npm install --include=optional --force --no-audit --no-fund --ignore-scripts COPY tsconfig.json tsconfig.app.json tsconfig.node.json vite.config.ts index.html eslint.config.js ./ COPY public ./public COPY src ./src RUN npm run build # ------- runtime stage ------- FROM nginx:1.27-alpine AS runtime COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build /app/dist /usr/share/nginx/html EXPOSE 80 HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ CMD wget -q --spider http://127.0.0.1/ || exit 1