# ============================================ # BatchMind OS — Full Stack Docker Image for Hugging Face Spaces # Backend (FastAPI) + Frontend (React/Vite) # ============================================ FROM python:3.11-slim # Prepare for Hugging Face Spaces (requires user 1000) RUN useradd -m -u 1000 user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONUNBUFFERED=1 \ PYTHONPATH=/home/user/app WORKDIR $HOME/app # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ gcc g++ curl && \ rm -rf /var/lib/apt/lists/* # Install Node.js for frontend build RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ apt-get install -y nodejs && \ rm -rf /var/lib/apt/lists/* # Copy requirements COPY --chown=user batchmind_os/requirements.txt requirements.txt # Switch to user for installs USER user # Install Python dependencies (CPU-only torch to save space) RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu \ torch --no-cache-dir && \ pip install --no-cache-dir -r requirements.txt && \ pip install --no-cache-dir requests # Copy entire project COPY --chown=user . $HOME/app/ # Build frontend WORKDIR $HOME/app/batchmind_os/frontend RUN npm install && npm run build # Back to root WORKDIR $HOME/app # Expose Hugging Face Port EXPOSE 7860 # Start script RUN chmod +x $HOME/app/start.sh # Run the app CMD ["/home/user/app/start.sh"]