FROM python:3.10-slim WORKDIR /app # System dependencies RUN apt-get update && apt-get install -y \ ffmpeg \ libsndfile1 \ git \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies before switching user COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Create user (USER ID 1000 is REQUIRED by Hugging Face!) RUN useradd -m -u 1000 user # Create output and cache directories with proper permissions RUN mkdir -p /data/output/one_audio && \ mkdir -p /data/hf_cache && \ mkdir -p /data/download && \ chown -R user:user /data # Copy application files COPY app.py . COPY README.md . # Switch to user (REQUIRED!) USER user # Environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONIOENCODING=UTF-8 \ HF_TOKEN=${HF_TOKEN} \ DATASET_ID=ayf3/numberblocks-audio \ HOME=/home/user # Expose port for Hugging Face EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')" # Run the web application CMD ["python", "app.py"]