# Use Node.js LTS version
FROM node:20-slim

# Install required dependencies for sharp (image processing)
RUN apt-get update && apt-get install -y \
    python3 \
    make \
    g++ \
    && rm -rf /var/lib/apt/lists/*

# Create app directory
WORKDIR /app

# Copy package files
COPY package*.json ./

# Install ALL dependencies (need sass for build)
RUN npm ci

# Copy application code
COPY . .

# Build CSS from SCSS
RUN npm run build:css

# Remove devDependencies after build
RUN npm prune --production

# Create necessary directories
RUN mkdir -p data uploads

# Expose port (Cloud Run will set PORT env variable)
EXPOSE 8080

# Set default port for Cloud Run
ENV PORT=8080

# Start the application
CMD ["node", "src/server.js"]

