# ═══════════════════════════════════════════════════════════════════════════ # CONSTITUENT DOCKERFILE # HuggingFace Docker Space — Node.js + FFmpeg streaming server # ═══════════════════════════════════════════════════════════════════════════ FROM node:20-slim # Install ffmpeg and system utilities RUN apt-get update && apt-get install -y \ ffmpeg \ procps \ curl \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy package files first for layer caching COPY package.json ./ # Install dependencies RUN npm install --omit=dev # Copy application files COPY server.js ./server.js # Create required directories RUN mkdir -p others/temp others/songs others/hls others/data # HuggingFace Spaces runs on port 7860 by default EXPOSE 7860 # Environment variables that MUST be set as HuggingFace Space secrets: # CONSTITUENT_OWNER_ID — the userId from your main DB who owns this space # MAIN_SERVER_SECRET — shared secret so only your main server can call add-movie # TMDB_KEY — (optional) for TMDB enrichment ENV PORT=7860 ENV NODE_ENV=production # Health check — HuggingFace polls this to decide if the space is healthy HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/constituent/health || exit 1 CMD ["node", "server.js"]