File size: 2,610 Bytes
3f792e8 3e27995 3f792e8 3e27995 3f792e8 3e27995 5de798e 3f792e8 3e27995 3f792e8 5de798e 3e27995 3f792e8 3e27995 3f792e8 3e27995 321254f cb974bb 3e27995 cb974bb b899c60 3e27995 321254f 5de798e 785835e fdcc0cf b899c60 3e27995 3f792e8 3e27995 5de798e 3f792e8 3e27995 3b1fac6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
git \
wget \
curl \
build-essential \
libsndfile1 \
libasound2-dev \
portaudio19-dev \
libportaudio2 \
libportaudiocpp0 \
libsndfile1-dev \
libflac-dev \
libvorbis-dev \
libogg-dev \
libmp3lame-dev \
libmad0-dev \
libtwolame-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libswresample-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies with proper error handling
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create necessary directories with proper permissions
RUN mkdir -p templates static uploads outputs model_cache temp_files demo_results demo_audio \
/tmp/matplotlib /tmp/fontconfig \
&& chmod -R 777 templates static \
&& chmod -R 777 uploads outputs model_cache temp_files demo_results demo_audio \
&& chmod -R 777 /tmp/matplotlib /tmp/fontconfig
# Set environment variables for Hugging Face Spaces
ENV PYTHONPATH=/app \
GRADIO_ANALYTICS_ENABLED=False \
HF_MODELS_CACHE=/app/model_cache \
OUTPUT_DIR=./outputs \
TEMP_DIR=./temp_files \
WHISPER_MODEL_SIZE=small \
TARGET_LANGUAGE=en \
MAX_WORKERS=1 \
USE_GPU=false \
HF_HOME=/app/model_cache \
TRANSFORMERS_CACHE=/app/model_cache \
TORCH_HOME=/app/model_cache \
XDG_CACHE_HOME=/app/model_cache \
PYANNOTE_CACHE=/app/model_cache \
MPLCONFIGDIR=/tmp/matplotlib \
HUGGINGFACE_HUB_CACHE=/app/model_cache \
HF_HUB_CACHE=/app/model_cache \
FONTCONFIG_PATH=/tmp/fontconfig \
# Fix for audio processing libraries
CTRANSLATE2_FORCE_CPU_ISA=generic \
# Disable problematic features
TF_CPP_MIN_LOG_LEVEL=2 \
TOKENIZERS_PARALLELISM=false \
# Fix executable stack issues
ONNX_EXECUTION_PROVIDER=cpu \
# Disable problematic optimizations
OMP_NUM_THREADS=1 \
# Suppress tensorboard warnings
TF_ENABLE_ONEDNN_OPTS=0 \
# Disable problematic features
DISABLE_ONNX_EXECUTION_PROVIDERS=CPUExecutionProvider
# Expose port for Hugging Face Spaces
EXPOSE 7860
# Health check for Hugging Face Spaces
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Preload models and start the application
CMD ["python", "startup.py"] |