# OMNL Bank production frontend
FROM node:20-alpine AS builder
WORKDIR /app
RUN corepack enable
COPY package.json pnpm-lock.yaml* ./
RUN pnpm install --frozen-lockfile 2>/dev/null || pnpm install
COPY . .
ARG VITE_TOKEN_AGGREGATION_URL=/api/v1
ARG VITE_SETTLEMENT_MIDDLEWARE_URL=/settlement
ARG VITE_DBIS_EXCHANGE_URL=/exchange
ENV VITE_TOKEN_AGGREGATION_URL=$VITE_TOKEN_AGGREGATION_URL
ENV VITE_SETTLEMENT_MIDDLEWARE_URL=$VITE_SETTLEMENT_MIDDLEWARE_URL
ENV VITE_DBIS_EXCHANGE_URL=$VITE_DBIS_EXCHANGE_URL
RUN pnpm run build

FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY deploy/nginx/frontend-spa.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
