Skip to content

Commit

Permalink
feat: Enhance CI workflow and Dockerfile for improved caching and dep…
Browse files Browse the repository at this point in the history
…endency management
  • Loading branch information
manascb1344 committed Feb 23, 2025
1 parent 034995b commit d2a8bbc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CACHE_FROM: type=registry,ref=${{ github.repository }}:buildcache
CACHE_TO: type=registry,ref=${{ github.repository }}:buildcache,mode=max

jobs:
build-and-push:
Expand All @@ -24,9 +26,15 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
driver-opts: |
image=moby/buildkit:latest
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
Expand All @@ -36,6 +44,15 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Cache Python dependencies
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
# Set image name based on branch
- name: Set image name and tags
id: meta
Expand Down Expand Up @@ -63,5 +80,12 @@ jobs:
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
cache-from: |
type=gha
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: |
type=gha,mode=max
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
platforms: linux/amd64
build-args: |
BUILDKIT_INLINE_CACHE=1
25 changes: 16 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ FROM nvidia/cuda:12.1.0-base-ubuntu22.04
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y \
python3.10 \
python3-pip \
ffmpeg \
Expand All @@ -13,9 +15,12 @@ RUN apt-get update && apt-get install -y \
espeak-ng \
&& rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
# Copy dependency files first
COPY requirements.txt pyproject.toml ./

# Install Python dependencies with caching
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install --no-cache-dir -r requirements.txt

# Clone the zonos repository and update submodules
RUN git clone https://github.com/Zyphra/Zonos.git /app/zonos \
Expand All @@ -31,12 +36,14 @@ RUN pip3 install /app/zonos \
sudachidict-full>=20241021 \
sudachipy>=0.6.10

# Install specific wheel files with GPU support
RUN FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE pip3 install flash-attn --no-build-isolation \
&& pip3 install --no-cache-dir https://github.com/state-spaces/mamba/releases/download/v2.2.4/mamba_ssm-2.2.4+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl \
&& pip3 install --no-cache-dir https://github.com/Dao-AILab/causal-conv1d/releases/download/v1.5.0.post8/causal_conv1d-1.5.0.post8+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
# Install GPU dependencies with caching
RUN --mount=type=cache,target=/root/.cache/pip \
FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE pip3 install flash-attn --no-build-isolation \
&& pip3 install --no-cache-dir \
https://github.com/state-spaces/mamba/releases/download/v2.2.4/mamba_ssm-2.2.4+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl \
https://github.com/Dao-AILab/causal-conv1d/releases/download/v1.5.0.post8/causal_conv1d-1.5.0.post8+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl

# Copy application code
# Copy application code last (changes most frequently)
COPY app/ app/
COPY pyproject.toml .

Expand Down

0 comments on commit d2a8bbc

Please sign in to comment.