# Use Python 3.9 slim image FROM python:3.9-slim # Set working directory WORKDIR /app # Copy requirements and packages list for better caching COPY packages.txt requirements.txt ./ # Install system dependencies from packages.txt (HuggingFace Spaces compatible) RUN apt-get update && \ xargs -r -a packages.txt apt-get install -y && \ rm -rf /var/lib/apt/lists/* # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy source code COPY . . # Create necessary directories RUN mkdir -p csgo/spawn config checkpoints cache && \ mkdir -p /tmp/torch /tmp/huggingface /tmp/transformers # Set environment variables ENV PYTHONPATH=/app/src:/app ENV OMP_NUM_THREADS=2 ENV MKL_NUM_THREADS=2 # Don't set CUDA_VISIBLE_DEVICES="" - let HF Spaces GPU be detected # ENV CUDA_VISIBLE_DEVICES="" # Removed - this disables GPU! # Set cache directories to writable locations ENV TORCH_HOME=/tmp/torch ENV HF_HOME=/tmp/huggingface ENV TRANSFORMERS_CACHE=/tmp/transformers # Expose port EXPOSE 7860 # Health check HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1 # Run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]