FROM rockylinux/rockylinux:10 AS build

RUN dnf install -y nodejs npm && dnf clean all

ARG VITE_API_BASE_URL=http://localhost:8000
ARG VITE_OTEL_COLLECTOR_ENDPOINT=http://localhost:4318

ENV VITE_API_BASE_URL=$VITE_API_BASE_URL \
    VITE_OTEL_COLLECTOR_ENDPOINT=$VITE_OTEL_COLLECTOR_ENDPOINT

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci --no-audit

COPY . .
RUN npm run build

FROM rockylinux/rockylinux:10 AS final

RUN dnf install -y nginx && dnf clean all

COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 8080

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