# NeuroTrack - Hugging Face Spaces Docker Deployment # Use official Python slim image for minimal footprint FROM python:3.10-slim # Avoid interactive prompts during build ENV DEBIAN_FRONTEND=noninteractive ENV PYTHONUNBUFFERED=1 # Install minimal build tools for packages that need compilation # Add only what's necessary; remove apt cache to keep image small RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ ca-certificates \ && rm -rf /var/lib/apt/lists/* # Create app directory WORKDIR /app # Set HF cache directory inside container (optional but recommended) ENV HF_HOME=/app/cache RUN mkdir -p /app/cache && chmod -R 777 /app/cache # Install Python dependencies first (layer caching optimization) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Create logs directory with proper permissions RUN mkdir -p /app/logs && chmod -R 777 /app/logs # Create data directory with proper permissions (for JSON data files) RUN chmod -R 755 /app/data 2>/dev/null || true # Expose the port expected by Spaces (default 7860, configurable via README app_port) EXPOSE 7860 # Use gunicorn as production-ready server # Bind to 0.0.0.0 and port 7860 (must match README app_port) # Single worker with threads keeps resource footprint modest for free Spaces CMD ["gunicorn", "app:app", "-w", "1", "--threads", "4", "-b", "0.0.0.0:7860", "--timeout", "120", "--access-logfile", "-", "--error-logfile", "-"]