# Build Stage
FROM docker.io/node:25.8.1-alpine3.23@sha256:5209bcaca9836eb3448b650396213dbe9d9a34d31840c2ae1f206cb2986a8543 as build

WORKDIR /app

# Ensure correct base URL for build-time (relative path)
ENV VITE_BASE_URL=""
ENV GENERATE_SOURCEMAP=false 

COPY package*.json ./
RUN npm install

COPY . .

RUN npm run build

# Production Stage
FROM docker.io/nginx:alpine3.23@sha256:f46cb72c7df02710e693e863a983ac42f6a9579058a59a35f1ae36c9958e4ce0

# Copy custom nginx config for reverse proxy
COPY nginx.conf /etc/nginx/conf.d/default.conf

# from Docker build stage move dist to nginx folder
COPY --from=build /app/dist /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
