FROM python:3.9-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ git \ build-essential \ libsndfile1 \ ffmpeg \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Create directories with permissive permissions RUN mkdir -p /.cache && chmod -R 777 /.cache \ && mkdir -p /app/.cache && chmod -R 777 /app/.cache \ && mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache/huggingface \ && mkdir -p /app/.cache/huggingface/token && chmod -R 777 /app/.cache/huggingface \ && echo "unused_dummy_token" > /app/.cache/huggingface/token \ && chmod 777 /app/.cache/huggingface/token \ && mkdir -p /usr/local/share/nltk_data && chmod -R 777 /usr/local/share/nltk_data \ && mkdir -p /tmp/librosa_cache && chmod -R 777 /tmp/librosa_cache # Create token file in the root directory in case it still looks there RUN mkdir -p /root/.cache/huggingface && chmod -R 777 /root/.cache/huggingface \ && echo "unused_dummy_token" > /root/.cache/huggingface/token \ && chmod 777 /root/.cache/huggingface/token # Create the data directories referenced in app.py RUN mkdir -p /app/data/uploads && chmod -R 777 /app/data/uploads \ && mkdir -p /app/data/results && chmod -R 777 /app/data/results \ && mkdir -p /app/data/configs && chmod -R 777 /app/data/configs # Copy requirements file COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -U pip && \ pip install --no-cache-dir -r requirements.txt # Clone VERSA repository RUN git clone https://github.com/wavlab-speech/versa.git && \ cd versa && \ pip install -e . # Set up data directories RUN mkdir -p /app/data/configs /app/data/uploads /app/data/results && \ chmod -R 777 /app/data # Copy universal metrics YAML file COPY universal_metrics.yaml /app/data/configs/ # Copy application code COPY app.py . # Create installation complete indicator RUN touch /app/versa/.installation_complete # Set port EXPOSE 7860 # Set environment variables ENV GRADIO_SERVER_NAME="0.0.0.0" ENV NLTK_DATA=/usr/local/share/nltk_data ENV PYTHONUNBUFFERED=1 ENV HF_HOME=/root/.cache/huggingface # Disable token verification for huggingface models ENV TRANSFORMERS_OFFLINE=1 ENV HF_DATASETS_OFFLINE=1 # Prevent huggingface from trying to access token ENV HF_HUB_OFFLINE=1 # Pre-download NLTK data RUN python -c "import nltk; nltk.download('punkt', download_dir='$NLTK_DATA'); nltk.download('stopwords', download_dir='$NLTK_DATA'); nltk.download('wordnet', download_dir='$NLTK_DATA')" # Set for Numba cache (error from https://github.com/librosa/librosa/issues/1156) RUN mkdir -m 777 /tmp/NUMBA_CACHE_DIR /tmp/MPLCONFIGDIR ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/ ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/ # Make everything accessible RUN echo "dummy_token" > /root/.cache/huggingface/token && chmod 777 /root/.cache/huggingface/token RUN chmod -R 777 /app RUN chmod -R 777 /usr/local/lib/python3.9/site-packages RUN chmod -R 777 /root # Run the application CMD ["python", "app.py"]