# CMS Development Dockerfile for Placebo.mk Strapi CMS

FROM node:20-slim

WORKDIR /app

# Install Python and build tools for any native modules
RUN apt-get update && apt-get install -y \
    python3 \
    make \
    g++ \
    && rm -rf /var/lib/apt/lists/*

# Install dependencies with better error handling
COPY package*.json ./
COPY package-lock.json* ./

# Fix permissions before npm install
RUN chown -R node:node /app

# Switch to non-root user for npm install
USER node

# Clear npm cache and install dependencies
RUN npm cache clean --force && \
    npm install

# Copy source code as node user
COPY --chown=node:node . .

# Expose port
EXPOSE 1337

# Start development server
CMD ["npm", "run", "develop"]