# ---- Build stage ---- FROM node:20-alpine AS build WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci COPY . . # Which origin the built app sends its API calls to. # # Vite inlines env vars at build time, so this MUST be a build arg - setting it # on the running container has no effect, the value is already baked into the # JS bundle. # # docker build --build-arg VITE_API_BASE_URL=https://mcp.nearle.ai.in . # # Left empty by default, which keeps requests relative and same-origin so the # nginx /api/* proxy below serves them. Set it when the API is on its own # domain - and add this app's origin to the backend's API_CORS_ORIGINS, or the # browser will block the responses. ARG VITE_API_BASE_URL="" ENV VITE_API_BASE_URL=$VITE_API_BASE_URL RUN npm run build # ---- Serve stage ---- FROM nginx:alpine WORKDIR /usr/share/nginx/html RUN rm -rf ./* COPY --from=build /app/dist/ . COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 80 3000 CMD ["nginx", "-g", "daemon off;"]