Spaces:
Sleeping
Sleeping
File size: 1,666 Bytes
2cb327c 2181828 2cb327c a921d56 2cb327c 5ef9cdf a921d56 2cb327c dff9b72 2cb327c d50eed9 a921d56 2cb327c | 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 | # Use a lightweight python image
FROM python:3.11-slim
# Install required system packages (as root)
RUN apt-get update && apt-get install -y \
ffmpeg \
espeak-ng \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install uv for blazing-fast pip installs
RUN pip install uv
# Copy requirements first for Docker layer caching
COPY requirements-ci-english.txt requirements-ci-hindi.txt ./
# ROOT CAUSE FIX: Install ALL dependencies in a SINGLE command
# so uv can resolve the full dependency graph at once.
#
# Previously, 3 separate `uv pip install` commands each resolved
# independently. The kokoro→misaki→spacy→typer→click chain needs
# click>=8.2.0 for Choice[T] generics, but a later install step
# was downgrading click, causing TypeError at import time.
#
# In GitHub Actions CI this works because everything is installed
# in one `uv pip install -r requirements.txt` call.
RUN uv pip install --system --no-cache \
fastapi uvicorn pydantic \
-r requirements-ci-english.txt \
-r requirements-ci-hindi.txt
# Pre-install the spacy model into system site-packages (as root).
# At runtime the app runs as non-root 'user', so pip downloads
# the model into user site-packages which spacy can't find.
RUN python -m spacy download en_core_web_sm
# Now create non-root user (HF Spaces requirement)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Set working directory and copy project
WORKDIR /app
COPY --chown=user:user . /app
# Hugging Face Spaces routes traffic to port 7860
EXPOSE 7860
# Run the FastAPI app
CMD ["uvicorn", "hf_app:app", "--host", "0.0.0.0", "--port", "7860"]
|