# ==========================================
# Stage 1: Build using Node.js + Bun
# ==========================================
FROM docker.io/library/node:26-alpine AS build
WORKDIR /app

RUN npm install -g bun

COPY package.json bun.lock ./
RUN bun install --frozen-lockfile --ignore-scripts

COPY . .

ENV CI=true
ENV NG_CLI_ANALYTICS=false

RUN bun run build

# ==========================================
# Stage 2: Serve the app using Nginx
# ==========================================
FROM docker.io/library/nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
COPY --from=build /app/dist/lmnp-frontend/browser /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

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