Files
catalogue_frontend/Dockerfile
Suriyakumarvijayanayagam 2d1f8e4156 Remove the empty VITE_API_BASE_URL build arg - it overrode .env.production
The deployed bundle shipped with no API base URL, so every request fell back to
a relative /api/*, which the frontend's nginx forwards to a backend:8000 service
this deployment does not have.

The cause was this Dockerfile. Vite gives a real environment variable precedence
over its .env files, so `ARG VITE_API_BASE_URL=""` followed by `ENV
VITE_API_BASE_URL=$VITE_API_BASE_URL` did not leave the value unset - it set it
to an empty string and overrode .env.production. Nothing about the build says
so; it just quietly produces a bundle with no API host.

Reproduced directly: building with VITE_API_BASE_URL="" in the environment
yields a bundle with no API URL, and building with the variable unset bakes in
https://mcp.nearle.ai.in from .env.production.

The value now comes from .env.production alone. Point a build elsewhere by
editing that file or adding .env.local; both are read by Vite and neither can be
silently empty.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 13:00:37 +05:30

34 lines
1.1 KiB
Docker

# ---- 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 calls comes from .env.production, committed next to
# this file, and Vite inlines it at build time.
#
# There is deliberately no ARG/ENV VITE_API_BASE_URL here. Vite gives a real
# environment variable precedence over its .env files, so declaring one with an
# empty default did not "leave it unset" - it actively set the value to an empty
# string and overrode .env.production. The build succeeded, the bundle shipped
# with no API base URL, and every request fell back to a relative /api/* that
# nginx forwards to a backend service this deployment does not have.
#
# To point a build somewhere else, edit .env.production, or add .env.local
# (ignored by git) - both are read by Vite and neither is silently empty.
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;"]