FROM node:20-alpine

# Install nginx
RUN apk add --no-cache nginx

WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy source code
COPY . .

# Copy nginx config
COPY nginx.conf /etc/nginx/http.d/default.conf

# Create nginx directories
RUN mkdir -p /run/nginx

# Expose ports
EXPOSE 80 5173

# Start both nginx and vite
CMD nginx && npm run dev -- --host 0.0.0.0 --port 5173
