Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +16 -21
Dockerfile
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
-
curl ca-certificates libgomp1 \
|
| 6 |
&& rm -rf /var/lib/apt/lists/*
|
| 7 |
|
| 8 |
# Install uv system-wide (build-time only)
|
|
@@ -15,39 +15,34 @@ WORKDIR /app
|
|
| 15 |
COPY pyproject.toml README.md ./
|
| 16 |
RUN uv sync --no-dev
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
ENV
|
|
|
|
| 20 |
|
| 21 |
-
# App code
|
| 22 |
COPY app.py ./
|
| 23 |
COPY static ./static
|
| 24 |
COPY clients ./clients
|
| 25 |
-
|
| 26 |
-
# Optional: models (or let app auto-download / mount them)
|
| 27 |
# COPY models ./models
|
| 28 |
-
# ENV KOKORO_MODEL=/app/models/kokoro-v1.0.int8.onnx \
|
| 29 |
-
# KOKORO_VOICES=/app/models/voices-v1.0.bin
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
|
|
|
| 35 |
ARG DOWNLOAD_MODELS=1
|
| 36 |
RUN mkdir -p /app/models && \
|
| 37 |
if [ "$DOWNLOAD_MODELS" = "1" ]; then \
|
| 38 |
echo "Downloading Kokoro model & voices..." && \
|
| 39 |
-
curl -
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
| 41 |
else \
|
| 42 |
echo "Skipping model download. Mount or COPY models into /app/models"; \
|
| 43 |
fi
|
| 44 |
|
| 45 |
-
|
| 46 |
-
ENV VIRTUAL_ENV=/app/.venv
|
| 47 |
-
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
| 48 |
-
|
| 49 |
-
# ... copy your app code ...
|
| 50 |
-
|
| 51 |
-
# call uvicorn through the venv's python (no PATH reliance)
|
| 52 |
CMD ["sh","-lc","exec /app/.venv/bin/python -m uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860}"]
|
| 53 |
-
|
|
|
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
+
curl ca-certificates libgomp1 libstdc++6 \
|
| 6 |
&& rm -rf /var/lib/apt/lists/*
|
| 7 |
|
| 8 |
# Install uv system-wide (build-time only)
|
|
|
|
| 15 |
COPY pyproject.toml README.md ./
|
| 16 |
RUN uv sync --no-dev
|
| 17 |
|
| 18 |
+
# Make venv easy to use
|
| 19 |
+
ENV VIRTUAL_ENV=/app/.venv
|
| 20 |
+
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
|
| 21 |
|
| 22 |
+
# ---- App code ----
|
| 23 |
COPY app.py ./
|
| 24 |
COPY static ./static
|
| 25 |
COPY clients ./clients
|
| 26 |
+
# If you want to COPY local models instead of downloading:
|
|
|
|
| 27 |
# COPY models ./models
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# ---- Model locations (NEEDED if you download at build) ----
|
| 30 |
+
ENV KOKORO_MODEL=/app/models/kokoro-v1.0.int8.onnx \
|
| 31 |
+
KOKORO_VOICES=/app/models/voices-v1.0.bin
|
| 32 |
|
| 33 |
+
# Optional auto-download at build
|
| 34 |
ARG DOWNLOAD_MODELS=1
|
| 35 |
RUN mkdir -p /app/models && \
|
| 36 |
if [ "$DOWNLOAD_MODELS" = "1" ]; then \
|
| 37 |
echo "Downloading Kokoro model & voices..." && \
|
| 38 |
+
curl -fL --retry 3 --retry-delay 2 -o "$KOKORO_MODEL" \
|
| 39 |
+
"https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/kokoro-v1.0.int8.onnx" && \
|
| 40 |
+
curl -fL --retry 3 --retry-delay 2 -o "$KOKORO_VOICES" \
|
| 41 |
+
"https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/voices-v1.0.bin" && \
|
| 42 |
+
test -s "$KOKORO_MODEL" && test -s "$KOKORO_VOICES"; \
|
| 43 |
else \
|
| 44 |
echo "Skipping model download. Mount or COPY models into /app/models"; \
|
| 45 |
fi
|
| 46 |
|
| 47 |
+
EXPOSE 7860
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
CMD ["sh","-lc","exec /app/.venv/bin/python -m uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860}"]
|
|
|