# Use official Node.js 20 slim image FROM node:20-slim # Set working directory WORKDIR /app # Ensure node user owns the working directory RUN chown -R node:node /app # Switch to standard non-root node user (UID 1000) for security and HF compatibility USER node # Copy package configuration files and assign ownership to node user COPY --chown=node:node package*.json ./ # Install dependencies RUN npm ci # Copy the rest of the workspace files with correct ownership COPY --chown=node:node . . # Run production build (compiles react front-end & esbuild server) RUN npm run build # Prune devDependencies to keep container size optimized RUN npm prune --production # Expose port 7860 (Hugging Face standard) ENV PORT=7860 EXPOSE 7860 # Start production server CMD ["npm", "start"]