Spaces:
Sleeping
Sleeping
File size: 1,612 Bytes
276abba 0015e4d 276abba 6c09cd7 276abba 0015e4d 6c09cd7 276abba 6c09cd7 276abba 44c0620 276abba 366afff 276abba |
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 |
FROM python:3.10-slim
WORKDIR /app
# Install dependencies and check espeak location
RUN apt-get update && apt-get install -y \
espeak-ng \
espeak-ng-data \
git \
libsndfile1 \
curl \
ffmpeg \
g++ \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /usr/share/espeak-ng-data \
&& ln -s /usr/lib/*/espeak-ng-data/* /usr/share/espeak-ng-data/
RUN git clone https://github.com/remsky/Kokoro-FastAPI.git .
# Install UV using the installer script
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
mv /root/.local/bin/uv /usr/local/bin/ && \
mv /root/.local/bin/uvx /usr/local/bin/
# Create non-root user and set up directories and permissions
RUN useradd -m -u 1000 appuser && \
mkdir -p /app/api/src/models/v1_0 && \
chown -R appuser:appuser /app
USER appuser
# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
uv venv --python 3.10 && \
uv sync --extra cpu
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONPATH=/app:/app/api \
PATH="/app/.venv/bin:$PATH" \
UV_LINK_MODE=copy \
USE_GPU=false \
PHONEMIZER_ESPEAK_PATH=/usr/bin \
PHONEMIZER_ESPEAK_DATA=/usr/share/espeak-ng-data \
ESPEAK_DATA_PATH=/usr/share/espeak-ng-data
ENV DOWNLOAD_MODEL=true
# Download model if enabled
RUN if [ "$DOWNLOAD_MODEL" = "true" ]; then \
python docker/scripts/download_model.py --output api/src/models/v1_0; \
fi
ENV DEVICE="cpu"
# Run FastAPI server through entrypoint.sh
CMD uv run --extra $DEVICE python -m uvicorn api.src.main:app --host 0.0.0.0 --port 8880 --log-level debug
|