mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-08-05 16:48:53 +00:00
ci: Docker workflow to build and slim images, update README for usage instructions
This commit is contained in:
parent
2649a0ba0c
commit
da324b0959
2 changed files with 53 additions and 32 deletions
65
.github/workflows/docker-publish.yml
vendored
65
.github/workflows/docker-publish.yml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: Docker Build and Publish
|
||||
name: Docker Build, Slim, and Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
|
@ -35,42 +35,64 @@ jobs:
|
|||
echo "GPU_IMAGE_NAME=${{ env.REGISTRY }}/$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')-gpu" >> $GITHUB_ENV
|
||||
echo "CPU_IMAGE_NAME=${{ env.REGISTRY }}/$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')-cpu" >> $GITHUB_ENV
|
||||
echo "UI_IMAGE_NAME=${{ env.REGISTRY }}/$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')-ui" >> $GITHUB_ENV
|
||||
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
|
||||
# Extract version tag if it exists
|
||||
- name: Set version tag
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
|
||||
# Build and push GPU version
|
||||
- name: Build and push GPU Docker image
|
||||
# Build GPU version
|
||||
- name: Build GPU Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/gpu/Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.GPU_IMAGE_NAME }}:latest
|
||||
${{ env.GPU_IMAGE_NAME }}:${{ env.VERSION }}
|
||||
push: false
|
||||
load: true
|
||||
tags: ${{ env.GPU_IMAGE_NAME }}:v0.1.0
|
||||
build-args: |
|
||||
DOCKER_BUILDKIT=1
|
||||
platforms: linux/amd64
|
||||
|
||||
# Build and push CPU version
|
||||
- name: Build and push CPU Docker image
|
||||
# Slim GPU version
|
||||
- name: Slim GPU Docker image
|
||||
uses: kitabisa/docker-slim-action@v1
|
||||
env:
|
||||
DSLIM_HTTP_PROBE: false
|
||||
with:
|
||||
target: ${{ env.GPU_IMAGE_NAME }}:v0.1.0
|
||||
tag: v0.1.0-slim
|
||||
|
||||
# Push GPU versions
|
||||
- name: Push GPU Docker images
|
||||
run: |
|
||||
docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0
|
||||
docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0-slim
|
||||
|
||||
# Build CPU version
|
||||
- name: Build CPU Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/cpu/Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.CPU_IMAGE_NAME }}:latest
|
||||
${{ env.CPU_IMAGE_NAME }}:${{ env.VERSION }}
|
||||
push: false
|
||||
load: true
|
||||
tags: ${{ env.CPU_IMAGE_NAME }}:v0.1.0
|
||||
build-args: |
|
||||
DOCKER_BUILDKIT=1
|
||||
platforms: linux/amd64
|
||||
|
||||
# Build and push UI version
|
||||
# Slim CPU version
|
||||
- name: Slim CPU Docker image
|
||||
uses: kitabisa/docker-slim-action@v1
|
||||
env:
|
||||
DSLIM_HTTP_PROBE: false
|
||||
with:
|
||||
target: ${{ env.CPU_IMAGE_NAME }}:v0.1.0
|
||||
tag: v0.1.0-slim
|
||||
|
||||
# Push CPU versions
|
||||
- name: Push CPU Docker images
|
||||
run: |
|
||||
docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0
|
||||
docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0-slim
|
||||
|
||||
# Build and push UI version (unchanged)
|
||||
- name: Build and push UI Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
|
@ -78,8 +100,7 @@ jobs:
|
|||
file: ./ui/Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.UI_IMAGE_NAME }}:latest
|
||||
${{ env.UI_IMAGE_NAME }}:${{ env.VERSION }}
|
||||
${{ env.UI_IMAGE_NAME }}:v0.1.0
|
||||
build-args: |
|
||||
DOCKER_BUILDKIT=1
|
||||
platforms: linux/amd64
|
||||
|
|
20
README.md
20
README.md
|
@ -24,7 +24,7 @@ Dockerized FastAPI wrapper for [Kokoro-82M](https://huggingface.co/hexgrad/Kokor
|
|||
The service can be accessed through either the API endpoints or the Gradio web interface.
|
||||
|
||||
1. Install prerequisites:
|
||||
- Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) + [Git](https://git-scm.com/downloads)
|
||||
- Install [Docker Desktop](https://www.docker.com/products/docker-desktop/)
|
||||
- Clone the repository:
|
||||
```bash
|
||||
git clone https://github.com/remsky/Kokoro-FastAPI.git
|
||||
|
@ -33,20 +33,20 @@ The service can be accessed through either the API endpoints or the Gradio web i
|
|||
|
||||
2. Start the service:
|
||||
|
||||
a. Using Docker Compose (recommended for full setup including UI):
|
||||
- Using Docker Compose (Full setup including UI):
|
||||
```bash
|
||||
docker compose up --build # for GPU
|
||||
#docker compose -f docker-compose.cpu.yml up --build # for CPU
|
||||
docker compose -f docker-compose.cpu.yml up --build # for CPU
|
||||
```
|
||||
|
||||
b. Running the API alone using Docker:
|
||||
- OR running the API alone using Docker (model + voice packs baked in):
|
||||
```bash
|
||||
# For CPU version
|
||||
docker run -p 8880:8880 kokoro-fastapi-cpu
|
||||
|
||||
# For GPU version (requires NVIDIA Container Toolkit)
|
||||
docker run --gpus all -p 8880:8880 kokoro-fastapi-gpu
|
||||
|
||||
docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest # CPU
|
||||
docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:latest # Nvidia GPU
|
||||
# Minified versions are available with `:latest-slim` tag.
|
||||
```
|
||||
|
||||
|
||||
2. Run locally as an OpenAI-Compatible Speech Endpoint
|
||||
```python
|
||||
from openai import OpenAI
|
||||
|
|
Loading…
Add table
Reference in a new issue