# syntax=docker/dockerfile:1 # # React portal: Vite build in node, served by nginx with the SPA history fallback. # Context is ./frontend. # # docker build -t hrms-frontend:local ./frontend FROM node:22-alpine AS build WORKDIR /src COPY package.json package-lock.json ./ RUN npm ci COPY . . # Vite inlines VITE_* at BUILD time, so the API origin is fixed when the image is # built, not when the container starts — rebuild the image to point it elsewhere. # `.env.production.local` outranks every other env file, so this wins over the empty # VITE_API_BASE in .env.production (which means "same origin, behind a proxy"). ARG VITE_API_BASE=http://localhost:8000 RUN printf 'VITE_API_BASE=%s\n' "$VITE_API_BASE" > .env.production.local \ && npm run build FROM nginx:1.27-alpine COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build /src/dist /usr/share/nginx/html EXPOSE 80