Spaces:
Running
Running
Add Dockerfile and Streamlit configuration; implement video download with alternative YouTube sources, enhance error handling, and improve file upload processing
aca25cc
unverified
FROM python:3.9-slim | |
# Set environment variables | |
ENV PYTHONUNBUFFERED=1 \ | |
PYTHONDONTWRITEBYTECODE=1 \ | |
MPLCONFIGDIR=/tmp/matplotlib \ | |
TRANSFORMERS_CACHE=/app/.cache/huggingface \ | |
HF_HOME=/app/.cache/huggingface \ | |
XDG_CACHE_HOME=/app/.cache \ | |
PYTHONIOENCODING=utf-8 \ | |
TOKENIZERS_PARALLELISM=false \ | |
HF_HUB_DISABLE_SYMLINKS_WARNING=1 | |
WORKDIR /app | |
# Install system dependencies | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
build-essential \ | |
curl \ | |
git \ | |
ffmpeg \ | |
libsndfile1 \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create necessary directories with proper permissions | |
RUN mkdir -p /app/tmp_model /tmp/matplotlib /app/uploads /app/.cache/huggingface /app/.streamlit /app/.config /root/.cache/huggingface | |
RUN chmod -R 777 /app/uploads /app/tmp_model /tmp/matplotlib /app/.cache /app/.streamlit /app/.config /root/.cache | |
# Create symbolic link to ensure both user and root can access cache | |
RUN ln -sf /app/.cache/huggingface /root/.cache/huggingface | |
# Copy requirements first (for better caching) | |
COPY requirements.txt . | |
# Install Python dependencies with specific order for compatibility | |
RUN pip install --no-cache-dir --upgrade pip && \ | |
pip install --no-cache-dir torch==2.0.1 torchaudio==2.0.2 && \ | |
pip install --no-cache-dir -r requirements.txt && \ | |
pip install --no-cache-dir git+https://github.com/speechbrain/speechbrain.git@v0.5.14 | |
# Copy source code | |
COPY src/ ./src/ | |
# Copy the Streamlit directory with configuration | |
COPY .streamlit/ ./.streamlit/ | |
# Set proper permissions on the Streamlit configuration | |
RUN chmod -R 755 ./.streamlit && \ | |
chmod 644 ./.streamlit/config.toml | |
# Expose port | |
EXPOSE 8501 | |
# Health check | |
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health | |
# Run the app | |
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"] | |