Spaces:
Sleeping
Sleeping
# syntax=docker/dockerfile:1 | |
FROM python:3.11-slim | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
curl ca-certificates libgomp1 libstdc++6 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install uv system-wide (build-time only) | |
ENV UV_INSTALL_DIR=/usr/local/bin | |
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && uv --version | |
WORKDIR /app | |
# Install deps into .venv | |
COPY pyproject.toml README.md ./ | |
RUN uv sync --no-dev | |
# Make venv easy to use | |
ENV VIRTUAL_ENV=/app/.venv | |
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" | |
# ---- App code ---- | |
COPY app.py ./ | |
COPY static ./static | |
COPY clients ./clients | |
# If you want to COPY local models instead of downloading: | |
# COPY models ./models | |
# ---- Model locations (NEEDED if you download at build) ---- | |
ENV KOKORO_MODEL=/app/models/kokoro-v1.0.int8.onnx \ | |
KOKORO_VOICES=/app/models/voices-v1.0.bin | |
# Optional auto-download at build | |
ARG DOWNLOAD_MODELS=1 | |
RUN mkdir -p /app/models && \ | |
if [ "$DOWNLOAD_MODELS" = "1" ]; then \ | |
echo "Downloading Kokoro model & voices..." && \ | |
curl -fL --retry 3 --retry-delay 2 -o "$KOKORO_MODEL" \ | |
"https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/kokoro-v1.0.int8.onnx" && \ | |
curl -fL --retry 3 --retry-delay 2 -o "$KOKORO_VOICES" \ | |
"https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/voices-v1.0.bin" && \ | |
test -s "$KOKORO_MODEL" && test -s "$KOKORO_VOICES"; \ | |
else \ | |
echo "Skipping model download. Mount or COPY models into /app/models"; \ | |
fi | |
EXPOSE 7860 | |
CMD ["sh","-lc","exec /app/.venv/bin/python -m uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860}"] | |