# Mana Loop - Next.js Game Docker Image (Development Build)

FROM node:20-alpine AS base
WORKDIR /app

# Install dependencies
RUN apk add --no-cache libc6-compat openssl

# Install bun
RUN npm install -g bun

# Copy package files first for better caching
COPY package.json bun.lockb* ./
COPY prisma ./prisma/

# Install dependencies
RUN bun install --frozen-lockfile

# Copy the rest of the application
COPY . .

# Development environment variables (no production optimizations)
ENV NODE_ENV=development
ENV NEXT_TELEMETRY_DISABLED=1
ENV DATABASE_URL="file:./dev.db"
ENV NEXT_DEV_MODE=true

# Generate Prisma client
RUN bunx prisma generate --schema=./prisma/schema.prisma

# Expose port
EXPOSE 3000

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

# Use development server (next dev) for better error messages and HMR
CMD ["bun", "run", "dev"]
