FROM node:20-slim WORKDIR /app # Copy and install dependencies first COPY package*.json ./ RUN npm install --legacy-peer-deps # Copy the rest of the app COPY . . # Create .next directory with proper permissions RUN mkdir -p .next && chmod -R 777 .next # Ensure node user owns the app RUN chown -R node:node /app # Switch to node user USER node EXPOSE 3000 CMD ["npm", "run", "dev"]