# Use official Node.js 20 slim image as the base FROM node:20-slim # Create app directory WORKDIR /app # Copy package files first to leverage Docker layer caching COPY package*.json ./ # Install only production dependencies RUN npm ci --omit=dev # Copy the rest of the application code COPY src/ ./src/ # Change ownership of the app directory to the pre-configured 'node' user (UID 1000) # Hugging Face Spaces requires running as UID 1000 RUN chown -R node:node /app # Switch to non-root user 'node' USER node # Set default environment variables ENV PORT=7860 ENV NODE_ENV=production # Expose the standard Hugging Face Spaces port EXPOSE 7860 # Run the node server CMD ["node", "src/server.js"]