| # Use the official Node.js 20 image | |
| FROM node:20-alpine | |
| # Set the working directory | |
| WORKDIR /app | |
| # Update npm to latest version to avoid the "Exit handler never called" error | |
| RUN npm install -g npm@latest | |
| # Copy package.json only (not package-lock.json) | |
| COPY package.json ./ | |
| # Clear npm cache and install dependencies fresh | |
| RUN npm cache clean --force && npm install --no-package-lock | |
| # Copy the rest of the application | |
| COPY . . | |
| # Build the Next.js application | |
| RUN npm run build | |
| # Expose Hugging Face default port | |
| EXPOSE 7860 | |
| # Start Next.js on port 7860 | |
| CMD ["npm", "start"] | |