# Use an official Python runtime as a parent image FROM python:3.10-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 ENV HOME=/tmp ENV HF_HOME=/tmp/huggingface ENV XDG_CACHE_HOME=/tmp/cache # Set the working directory in the container WORKDIR /app # Install system dependencies for librosa and audio processing RUN apt-get update && apt-get install -y \ libsndfile1 \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Copy the requirements file into the container COPY requirements_render.txt . # Install dependencies RUN pip install --no-cache-dir -r requirements_render.txt # Copy the entire project into the container COPY . . # Create necessary directories in /tmp and set permissions RUN mkdir -p /tmp/huggingface /tmp/cache /tmp/matplotlib /tmp/numba /app/app/tmp/uploads && \ chmod -R 777 /tmp /app/app/tmp/uploads # Expose the port Render/HF uses EXPOSE 7860 # Ensure the app user has permissions RUN chown -R 1000:1000 /app USER 1000 # Set PYTHONPATH so 'utils' can be found easily ENV PYTHONPATH=/app # Command to run the application # We run from the root /app and point to app.main:app # Increased timeout to 300 to handle slow TensorFlow initialization on Free plans CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "300", "--workers", "1", "--log-level", "debug", "--error-logfile", "-", "--access-logfile", "-", "app.main:app"]