# Production Dockerfile for gameno-front (Node + Vite)
FROM node:22-alpine

WORKDIR /app

# Copy package descriptors and install dependencies
COPY package*.json ./
RUN npm ci

# Copy application source code
COPY . .

# Build argument for API base URL (can be overridden at build time)
ARG VITE_API_BASE_URL
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}

# Build static application
RUN npm run build

EXPOSE 5174

# Healthcheck targeting port 5174
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD wget --no-verbose --tries=1 --spider http://localhost:5174/ || exit 1

CMD ["npx", "vite", "preview", "--host", "0.0.0.0", "--port", "5174"]
