Update Dockerfile
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142# Base imageFROM python:3.10-slimENV PIP_NO_CACHE_DIR=1 \PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1# System deps (sndfile needed by soundfile/audiotools)RUN apt-get update && apt-get install -y --no-install-recommends \ca-certificates curl libsndfile1 && \rm -rf /var/lib/apt/lists/*# WorkdirWORKDIR /code# Writable caches for HF/Transformers (HF Spaces is root; 0777 is fine here)RUN useradd -m user && \mkdir -p /home/user/.cache/huggingface \/home/user/.cache/hfhub \/home/user/.cache/transformers \/home/user/files \/home/user/tmp && \chown -R user:user /home/user && chmod -R 0777 /home/userENV HF_HOME=/home/user/.cache/huggingface \HUGGINGFACE_HUB_CACHE=/home/user/.cache/hfhub \TRANSFORMERS_CACHE=/home/user/.cache/transformers \TMPDIR=/home/user/tmp# ✅ Install CPU-only PyTorch + Torchaudio (avoid CUDA libs)RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu \torch==2.3.1 torchaudio==2.3.1# Python depsCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt# AppCOPY app.py .EXPOSE 7860CMD ["uvicorn","app:app","--host","0.0.0.0","--port","7860","--no-server-header"]12345678910111213141516171819202122232425262728293031323334353637383940414243# Fast, tiny baseFROM python:3.10-slim# System deps: curl, espeak-ng (phonemizer), and libsndfile (if needed later)RUN apt-get update && apt-get install -y --no-install-recommends \ca-certificates curl espeak-ng libsndfile1 \&& rm -rf /var/lib/apt/lists/*WORKDIR /code# --- Install Piper CLI (prebuilt binary) ---# Get the latest stable release name if you prefer; here we pin to a known URL# x86_64 Linux binary from rhasspy/piperRUN curl -L -o /usr/local/bin/piper \https://github.com/rhasspy/piper/releases/download/v1.2.0/piper_linux_x64 \&& chmod +x /usr/local/bin/piper# Create writable app dirsRUN mkdir -p /tmp/brain_app/files /tmp/brain_app/tmp /home/user/voices# --- Download a FAST English voice (good quality) ---# You can change these to another piper voice if you like.ENV VOICE_NAME=en_US-amy-mediumENV VOICE_DIR=/home/user/voicesENV VOICE_ONNX=${VOICE_DIR}/${VOICE_NAME}.onnxENV VOICE_JSON=${VOICE_DIR}/${VOICE_NAME}.onnx.json# Voice files from rhasspy/piper voices repo (Amy is a solid, fast pick)RUN curl -L -o ${VOICE_ONNX} \https://github.com/rhasspy/piper/releases/download/2024.04.17/${VOICE_NAME}.onnx \&& curl -L -o ${VOICE_JSON} \https://github.com/rhasspy/piper/releases/download/2024.04.17/${VOICE_NAME}.onnx.json# Python deps (very small set)COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt# AppCOPY app.py .# Expose for HF SpacesENV PORT=7860CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
Dockerfile+31-30