Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Docker Build and Publish

on:
push:
branches: [ "master" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "master" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v3.5.0
with:
cosign-release: 'v2.2.4'

# Set up Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=tag
type=sha

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
run: |
if [ -z "$DIGEST" ]; then
echo "Digest is empty, skipping signing."
exit 0
fi
echo "Signing image with digest $DIGEST..."
if echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}; then
echo "Signing succeeded."
else
echo "Signing failed, but continuing workflow."
exit 0
fi
11 changes: 11 additions & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.git
.gitignore
venv/
__pycache__/
*.pyc
*.pyo
*.pyd
.DS_Store
logs/
hf_space/
docker/
51 changes: 51 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Use NVIDIA CUDA base image
FROM nvidia/cuda:12.8.0-devel-ubuntu22.04

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV TORCH_CUDA_ARCH_LIST="8.0;8.6;8.9;9.0"

# Install system dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
python3-dev \
git \
libsndfile1 \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/*

# Create symbolic link for python
RUN ln -s /usr/bin/python3 /usr/bin/python

# Set working directory
WORKDIR /app

# Copy requirements file
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY maya1/ maya1/
COPY server.sh .
COPY samples.txt .
COPY README.md .

# Create logs directory
RUN mkdir -p logs

# Expose the API port
EXPOSE 8000

# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1

# Run the application
CMD ["uvicorn", "maya1.api_v2:app", "--host", "0.0.0.0", "--port", "8000"]
51 changes: 51 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Maya1 TTS Docker Deployment

This directory contains the configuration for deploying Maya1 TTS using Docker.

## Prerequisites

- Docker installed
- NVIDIA GPU with drivers installed
- NVIDIA Container Toolkit installed (for GPU support)

## Files

- `Dockerfile`: The Docker image definition.
- `docker-gpu.sh`: Helper script to build and run the container with GPU support.
- `.dockerignore`: Specifies files to exclude from the build context.

## Usage

### Using the helper script

Run the following command from the project root or the `docker` directory:

```bash
./docker/docker-gpu.sh
```

This will:
1. Build the Docker image `maya1-tts`.
2. Run the container with all available GPUs.
3. Expose the API on port 8000.

### Manual Build and Run

**Build:**

```bash
docker build -t maya1-tts -f docker/Dockerfile .
```

**Run:**

```bash
docker run --gpus all --ipc=host -p 8000:8000 maya1-tts
```

## Notes

- The container uses `nvidia/cuda:12.1.1-devel-ubuntu22.04` as the base image.
- It installs Python 3.10 and all dependencies from `requirements.txt`.
- The API is available at `http://localhost:8000`.
- Health check is available at `http://localhost:8000/health`.
31 changes: 31 additions & 0 deletions docker/docker-gpu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'

echo -e "${BLUE}Building Maya1 TTS Docker Image...${NC}"

# Navigate to project root
cd "$(dirname "$0")/.."

# Build the image
docker build -t maya1-tts -f docker/Dockerfile .

if [ $? -eq 0 ]; then
echo -e "${GREEN}Build successful!${NC}"
echo -e "${BLUE}Starting container with GPU support...${NC}"

# Run the container
docker run --gpus all \
--ipc=host \
-p 8000:8000 \
--name maya1-tts-server \
--rm \
-it \
maya1-tts
else
echo -e "\033[0;31mBuild failed!${NC}"
exit 1
fi