# Use an official Node runtime as a parent image FROM node:22-alpine # Hugging Face Spaces require running as a non-root user (UID 1000) # The official 'node' image already provides a user named 'node' with UID 1000 # Set the working directory WORKDIR /app # Give the non-root user ownership of the working directory RUN chown -R node:node /app # Switch to the non-root user USER node # Copy package.json and permissions COPY --chown=node:node package*.json ./ # Install dependencies RUN npm install # Copy the rest of the application code COPY --chown=node:node . . # Build the frontend and backend RUN npm run build # Set environment to production ENV NODE_ENV=production # Hugging Face default port is 7860 ENV PORT=7860 EXPOSE 7860 1935 # Start the production server CMD ["npm", "start"]