FROM node:18-alpine AS builder

# Set working directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package.json ./

# Install dependencies
RUN npm install

# Copy project files
COPY . .

# Build the project
RUN npm run start

# Final stage
FROM node:18-alpine

# Set working directory
WORKDIR /app

# Copy built files from builder
COPY --from=builder /app ./

# Expose the application port (sesuaikan dengan port yang digunakan di package.json)
EXPOSE 8000

# Jalankan aplikasi dengan npm run preview
CMD ["npm", "run", "preview"]
