FROM node:20-slim # Hugging Face Spaces runs as user 1000 RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Copy dependency specifications first for Docker layer caching COPY --chown=user:user package*.json ./ # Install production and build dependencies RUN npm install # Copy application files COPY --chown=user:user . . # Expose port 7860 (standard Hugging Face Spaces port) EXPOSE 7860 ENV PORT=7860 ENV NODE_ENV=production CMD ["npm", "start"]