Audio_Classification / Dockerfile
gargaman07's picture
Update Dockerfile
76c02cd verified
# Use an official Python runtime as a parent image
FROM python:3.10-slim
# Set the working directory in the container
WORKDIR /app
# Install system dependencies
# - git: for installing python packages from git
# - ffmpeg: for audio processing with pydub/librosa
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
ffmpeg \
libsndfile1 \
libsndfile1-dev \
build-essential \
python3-dev \
libhdf5-dev \
llvm \
&& rm -rf /var/lib/apt/lists/*
ENV NUMBA_CACHE_DIR=/tmp/numba_cache
ENV NUMBA_DISABLE_JIT=1
ENV NUMBA_DISABLE_CUDA=1
ENV NUMBA_DISABLE_LLVM=1
ENV NUMBA_LLVM_DEBUG=0
ENV NUMBA_DEBUG=0
ENV NUMBA_WARNINGS=0
ENV PYTHONPATH=/app
ENV TF_CPP_MIN_LOG_LEVEL=2
ENV LLVM_CONFIG=/usr/bin/llvm-config
RUN mkdir -p /tmp/numba_cache && chmod 777 /tmp/numba_cache
# Copy the requirements file into the container
COPY requirements.txt .
# Install Python dependencies
# Using --no-cache-dir to reduce image size
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code into the container
COPY . .
# Make port 7860 available to the world outside this container
# Hugging Face Spaces often use this port by default
EXPOSE 7860
# Define environment variable for the port (optional, uvicorn command below sets it)
ENV PORT 7860
# Run the application
# Use 0.0.0.0 to allow external connections
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]