# GermanApp Frontend Dockerfile
# React 19 + TypeScript + Vite Application
# Multi-stage build for production optimization

# ============================================
# Build Stage
# ============================================
FROM node:20-alpine AS build
WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm ci

# Copy source files
COPY . .

# Build the application
RUN npm run build

# ============================================
# Runtime Stage
# ============================================
FROM nginx:alpine AS runtime
WORKDIR /usr/share/nginx/html

# Copy built files from build stage
COPY --from=build /app/dist .

# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose port
EXPOSE 3000

# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
    CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1

# Entry point (nginx runs by default)
CMD ["nginx", "-g", "daemon off;"]
