# Multi-stage build for production
FROM node:18-alpine AS base
WORKDIR /app
COPY package*.json ./
RUN npm ci

# Development stage
FROM base AS dev
COPY . .
ENV HOST=0.0.0.0 PORT=12000
EXPOSE 12000
CMD ["npm", "start"]

# Production build stage
FROM base AS build
COPY . .
RUN npm run build

# Production serve stage
FROM nginx:alpine AS prod
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
