# Build stage FROM node:20-alpine AS build WORKDIR /app # Bake the API base URL into the Vite bundle at build time. # Default is the relative "/api" — works when the app is served from the same # origin as the /api reverse proxy (nginx in front of the backend). ARG VITE_API_BASE_URL=/api ENV VITE_API_BASE_URL=$VITE_API_BASE_URL # Copy frontend manifest first for better layer caching COPY frontend/package*.json ./ RUN npm install # Copy the rest of the frontend source and build COPY frontend/ . RUN npm run build # ------------------------------------------------------------------- # Serve stage — nginx # ------------------------------------------------------------------- FROM nginx:1.24-alpine # Copy built static assets from the build stage COPY --from=build /app/dist /usr/share/nginx/html # Copy nginx config (path is relative to the build context, which is the project root) COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]