# Build stage
FROM node:20-alpine AS builder

WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm ci --omit=dev

# Copy source code
COPY . .

# Build the application
RUN npm run build

# Production stage
FROM node:20-alpine AS production

WORKDIR /app

# Copy built application from builder stage
COPY --from=builder /app/.output ./

# Create music directory for volume mounting
RUN mkdir -p /app/public/music

# Expose port
EXPOSE 3000

# Start the application
CMD ["node", "server/index.mjs"]