FROM node:24-bookworm-slim AS build

WORKDIR /workspace

ARG VUE_APP_N8N_URL=http://localhost:15678
ARG VUE_APP_N8N_CHAT_URL=
ARG VUE_APP_MINIO_PUBLIC_URL=http://localhost:19000/dataops-bucket
ARG VUE_APP_PREVIEW_URL=
ENV VUE_APP_N8N_URL=${VUE_APP_N8N_URL}
ENV VUE_APP_N8N_CHAT_URL=${VUE_APP_N8N_CHAT_URL}
ENV VUE_APP_MINIO_PUBLIC_URL=${VUE_APP_MINIO_PUBLIC_URL}
ENV VUE_APP_PREVIEW_URL=${VUE_APP_PREVIEW_URL}

COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci --legacy-peer-deps

COPY frontend/ ./
RUN npm run build

FROM nginx:1.27-alpine

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

EXPOSE 80
