FROM node:20-alpine

# Install libc6-compat for compatibility with native node modules
RUN apk add --no-cache libc6-compat

WORKDIR /app

# Copy dependency files first
COPY sistem-km-next/package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application files
COPY sistem-km-next/ .

# Expose Next.js port
EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

# Start Next.js app in development mode
CMD ["npm", "run", "dev"]
