Kokoro-FastAPI/docker/gpu/Dockerfile
faltiska f18ab7dff7 Updated commands for pushing to and running from ECR.
Updated python startup logic for simplicity, considering that I don't do warmup anymore.
2025-06-09 11:17:13 +03:00

74 lines
No EOL
2.7 KiB
Docker

FROM --platform=$BUILDPLATFORM nvidia/cuda:12.9.0-base-ubuntu24.04
# Set non-interactive frontend
ENV DEBIAN_FRONTEND=noninteractive
# Install Python and other dependencies
RUN apt-get update -y && \
apt-get install -y python3 python3-venv libsndfile1 curl ffmpeg g++ && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
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/ && \
useradd -m -u 1001 appuser && \
mkdir -p /app/api/src/models/v1_0 && \
chown -R appuser:appuser /app
USER appuser
WORKDIR /app
ENV PHONEMIZER_ESPEAK_PATH=/usr/bin \
PHONEMIZER_ESPEAK_DATA=/usr/share/espeak-ng-data \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app:/app/api \
PATH="/app/.venv/bin:$PATH" \
UV_LINK_MODE=copy \
USE_GPU=true \
DEVICE="gpu"
COPY --chown=appuser:appuser pyproject.toml ./pyproject.toml
COPY --chown=appuser:appuser api ./api
COPY --chown=appuser:appuser web ./web
COPY --chown=appuser:appuser docker/scripts/ ./
RUN chmod +x ./entrypoint.sh
RUN --mount=type=cache,target=/root/.cache/uv \
uv venv --python 3.10 && \
uv sync --extra gpu && \
uv cache clean && \
python download_model.py --output api/src/models/v1_0
# Run FastAPI server through entrypoint.sh
CMD ["./entrypoint.sh"]
# If you want to test the docker image locally, run this from the project root:
# docker build -f docker\gpu\Dockerfile -t evie/kokorotts .
# Run it with:
# docker run -p 8880:8880 --name kokorotts evie/kokorotts
#
# You can log into the container with
# docker exec -it kokorotts /bin/bash
#
# Other commands:
# 1. Stop and remove container
# docker container remove kokorotts
#
# 2. List or remove images
# docker images
# docker image remove evie/kokorotts
#
# See docs for pushing to ECR
# https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html
# This is my private repo:
# https://eu-west-1.console.aws.amazon.com/ecr/private-registry/repositories?region=eu-west-1
# I can get the dodcker push / pull commands from there.
#
# SSH keys for logging into EC2 containers:
# https://eu-west-1.console.aws.amazon.com/ec2/home?region=eu-west-1#KeyPairs:
#
# aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 678811077621.dkr.ecr.eu-west-1.amazonaws.com
# docker build -f docker\gpu\Dockerfile -t evie/kokorotts .
# docker tag evie/kokorotts:latest 678811077621.dkr.ecr.eu-west-1.amazonaws.com/evie/kokorotts:latest
# docker push 678811077621.dkr.ecr.eu-west-1.amazonaws.com/evie/kokorotts:latest
# docker run --gpus all -p 8880:8880 --name kokorotts 678811077621.dkr.ecr.eu-west-1.amazonaws.com/evie/kokorotts