mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-09-18 21:39:23 +00:00
Add Docker build scripts for CPU and GPU images, update Dockerfiles to include project files and adjust ONNX usage
This commit is contained in:
parent
8eb3525382
commit
c92045c598
3 changed files with 39 additions and 2 deletions
33
docker/build.sh
Executable file
33
docker/build.sh
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Get version from argument or use default
|
||||
VERSION=${1:-"latest"}
|
||||
|
||||
# GitHub Container Registry settings
|
||||
REGISTRY="ghcr.io"
|
||||
OWNER="remsky"
|
||||
REPO="kokoro-fastapi"
|
||||
|
||||
# Build CPU image
|
||||
echo "Building CPU image..."
|
||||
docker build -t ${REGISTRY}/${OWNER}/${REPO}-cpu:${VERSION} -f docker/cpu/Dockerfile .
|
||||
docker tag ${REGISTRY}/${OWNER}/${REPO}-cpu:${VERSION} ${REGISTRY}/${OWNER}/${REPO}-cpu:latest
|
||||
|
||||
# Build GPU image
|
||||
echo "Building GPU image..."
|
||||
docker build -t ${REGISTRY}/${OWNER}/${REPO}-gpu:${VERSION} -f docker/gpu/Dockerfile .
|
||||
docker tag ${REGISTRY}/${OWNER}/${REPO}-gpu:${VERSION} ${REGISTRY}/${OWNER}/${REPO}-gpu:latest
|
||||
|
||||
echo "Build complete!"
|
||||
echo "Created images:"
|
||||
echo "- ${REGISTRY}/${OWNER}/${REPO}-cpu:${VERSION}"
|
||||
echo "- ${REGISTRY}/${OWNER}/${REPO}-cpu:latest"
|
||||
echo "- ${REGISTRY}/${OWNER}/${REPO}-gpu:${VERSION}"
|
||||
echo "- ${REGISTRY}/${OWNER}/${REPO}-gpu:latest"
|
||||
|
||||
echo -e "\nTo push to GitHub Container Registry:"
|
||||
echo "docker push ${REGISTRY}/${OWNER}/${REPO}-cpu:${VERSION}"
|
||||
echo "docker push ${REGISTRY}/${OWNER}/${REPO}-cpu:latest"
|
||||
echo "docker push ${REGISTRY}/${OWNER}/${REPO}-gpu:${VERSION}"
|
||||
echo "docker push ${REGISTRY}/${OWNER}/${REPO}-gpu:latest"
|
|
@ -31,6 +31,10 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
|||
uv venv && \
|
||||
uv sync --extra cpu --no-install-project
|
||||
|
||||
# Copy project files including models
|
||||
COPY --chown=appuser:appuser api ./api
|
||||
COPY --chown=appuser:appuser web ./web
|
||||
|
||||
# Copy project files
|
||||
COPY --chown=appuser:appuser api ./api
|
||||
COPY --chown=appuser:appuser web ./web
|
||||
|
@ -45,7 +49,7 @@ ENV PYTHONPATH=/app
|
|||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
ENV UV_LINK_MODE=copy
|
||||
ENV USE_GPU=false
|
||||
ENV USE_ONNX=true
|
||||
ENV USE_ONNX=false
|
||||
|
||||
# Run FastAPI server
|
||||
CMD ["uv", "run", "python", "-m", "uvicorn", "api.src.main:app", "--host", "0.0.0.0", "--port", "8880", "--log-level", "debug"]
|
||||
|
|
|
@ -35,7 +35,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
|||
uv venv && \
|
||||
uv sync --extra gpu
|
||||
|
||||
# Copy project files
|
||||
# Copy project files including models
|
||||
COPY --chown=appuser:appuser api ./api
|
||||
COPY --chown=appuser:appuser web ./web
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue