| FROM node:20-slim | |
| # HF Spaces runs containers as a non-root user (uid 1000). Create it so the | |
| # app's data/ dir under WORKDIR stays writable at runtime. | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR /home/user/app | |
| # Install deps (incl. dev — needed for `next build` and tailwind/typescript). | |
| COPY --chown=user package.json package-lock.json ./ | |
| RUN npm install --include=dev | |
| # App source. | |
| COPY --chown=user . . | |
| # Build Next.js. | |
| RUN npm run build | |
| ENV NODE_ENV=production \ | |
| PORT=7860 | |
| EXPOSE 7860 | |
| # Custom server merges Next + WebSocket on the single exposed port. | |
| CMD ["npm", "start"] | |