# syntax=docker/dockerfile:1

# =========
#  Builder
# =========
FROM node:lts-alpine AS builder
WORKDIR /app

# Install dependencies first (better layer caching)
COPY ui/package.json ui/package-lock.json ./
RUN npm ci

# Copy the rest of the UI source and build
COPY ui/ ./
RUN npm run build

# =========
#  Runtime
# =========
FROM nginx:alpine AS runtime

# Replace the default nginx config with our custom one
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf

# Copy the built assets from the builder stage
COPY --from=builder /app/dist /usr/share/nginx/html

EXPOSE 80

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