Skip to content

Commit ca5d650

Browse files
authored
.github: Create CI for live pipelines docker images (#282)
* .github: Create initial CI pipeline for live images * Dummy change to rebuild * .github: Add cleanup before pipeline images * .github: Rename noop job for consistency * Add fail-fast: false confyui still needs ton of disk * .github: Add some conditions to image build * docker/liveportrait: Print more friendly wget output * .github: Skip only the docker build step for base * .github: Add condition for noop image too * .github: Fix title * .github: Cleanup hosted runner deeper * docker/liveportrait: Dummy change on dockerfile to see if it builds * .github: Debugging base pipeline rebuild check * .github: Add proper permissions to jobs * docker: Try changing streamdiffusion/noop dockerfiles * .github: Skip base image cleanup step if no build * .github: Use custom plugin to detect changed files * .github: Increase fetch depth * .github: Add conditions for noop job as well * Revert "docker: Try changing streamdiffusion/noop dockerfiles" This reverts commit 603ae19. * .github: Fix debug steps * .github: Remove debug step. It works! * .github: Rename to base_dockerfile for clarity * runner/run: Allow run-lv2v to be used with noop image
1 parent f3c00fe commit ca5d650

File tree

6 files changed

+285
-13
lines changed

6 files changed

+285
-13
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Cleanup Runner'
2+
description: 'Cleans up GitHub-hosted runner to free up disk space for large builds'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Cleanup hosted runner
7+
shell: bash
8+
run: |
9+
# Remove unnecessary packages
10+
sudo apt purge -yqq dotnet-* mono-* llvm-* libllvm* powershell* openjdk-* \
11+
temurin-* mongodb-* firefox mysql-* \
12+
hhvm google-chrome-stable \
13+
libgl1-mesa-dri microsoft-edge-stable azure-cli || true
14+
15+
# Clean apt cache
16+
sudo apt clean
17+
sudo apt autoremove -y
18+
19+
# Remove large directories
20+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android
21+
sudo rm -rf /usr/local/share/chromium /usr/local/share/chrome
22+
sudo rm -rf /usr/local/.ghcup /usr/local/share/powershell
23+
sudo rm -rf /opt/hostedtoolcache/* /usr/local/lib/node_modules
24+
25+
# Clean npm and yarn caches
26+
npm cache clean --force || true
27+
yarn cache clean || true
28+
29+
# Remove Docker images and build cache
30+
docker system prune -af
31+
32+
# Show available space after cleanup
33+
df -h
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
name: Build ai-runner live pipeline Docker images
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "runner/docker/Dockerfile.live-*"
7+
- "runner/app/**"
8+
- "runner/images/**"
9+
push:
10+
branches:
11+
- main
12+
tags:
13+
- '*'
14+
paths:
15+
- "runner/docker/Dockerfile.live-*"
16+
- "runner/app/**"
17+
- "runner/images/**"
18+
workflow_dispatch:
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
build-common-base:
26+
name: Build common live base image
27+
permissions:
28+
pull-requests: read
29+
runs-on: ubuntu-20.04
30+
steps:
31+
- name: Check out code
32+
uses: actions/[email protected]
33+
with:
34+
fetch-depth: 50
35+
ref: ${{ github.event.pull_request.head.sha }}
36+
37+
- name: Get changed files
38+
id: changed-files
39+
uses: tj-actions/changed-files@v45
40+
with:
41+
files: |
42+
runner/docker/Dockerfile.live-base
43+
44+
- name: Check if build needed
45+
id: check_build
46+
if: |
47+
github.event_name == 'workflow_dispatch' ||
48+
github.event_name == 'push' ||
49+
(
50+
github.event_name == 'pull_request' &&
51+
github.event.pull_request.head.repo.full_name == github.repository &&
52+
steps.changed-files.outputs.any_changed == 'true'
53+
)
54+
run: echo "should_build=true" >> $GITHUB_OUTPUT
55+
56+
- name: Cleanup hosted runner
57+
uses: ./.github/actions/cleanup-runner
58+
if: steps.check_build.outputs.should_build == 'true'
59+
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v3
62+
63+
- name: Login to DockerHub
64+
uses: docker/login-action@v3
65+
with:
66+
username: ${{ secrets.CI_DOCKERHUB_USERNAME }}
67+
password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
68+
69+
- name: Build and push live-base image
70+
uses: docker/build-push-action@v5
71+
if: steps.check_build.outputs.should_build == 'true'
72+
with:
73+
context: "{{defaultContext}}:runner"
74+
platforms: linux/amd64
75+
push: ${{ github.event_name != 'pull_request' }}
76+
tags: livepeer/ai-runner:live-base
77+
file: docker/Dockerfile.live-base
78+
cache-from: type=registry,ref=livepeerci/build:cache
79+
cache-to: type=registry,ref=livepeerci/build:cache,mode=max
80+
81+
build-pipeline-images:
82+
name: Build pipeline images
83+
needs: build-common-base
84+
runs-on: ubuntu-20.04
85+
permissions:
86+
pull-requests: read
87+
strategy:
88+
matrix:
89+
pipeline: [streamdiffusion, comfyui, liveportrait]
90+
fail-fast: false
91+
steps:
92+
- name: Check out code
93+
uses: actions/[email protected]
94+
with:
95+
fetch-depth: 50
96+
ref: ${{ github.event.pull_request.head.sha }}
97+
98+
- name: Get changed files
99+
id: changed-files
100+
uses: tj-actions/changed-files@v45
101+
with:
102+
files_yaml: |
103+
base_dockerfile:
104+
- runner/docker/Dockerfile.live-base-${{ matrix.pipeline }}
105+
liveportrait:
106+
- runner/images/**
107+
- runner/requirements-liveportrait.txt
108+
109+
- name: Cleanup hosted runner
110+
uses: ./.github/actions/cleanup-runner
111+
112+
- name: Set up Docker Buildx
113+
uses: docker/setup-buildx-action@v3
114+
115+
- name: Login to DockerHub
116+
uses: docker/login-action@v3
117+
with:
118+
username: ${{ secrets.CI_DOCKERHUB_USERNAME }}
119+
password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
120+
121+
- name: Build and push pipeline base image
122+
uses: docker/build-push-action@v5
123+
if: |
124+
github.event_name == 'workflow_dispatch' ||
125+
github.event_name == 'push' ||
126+
(
127+
github.event_name == 'pull_request' &&
128+
github.event.pull_request.head.repo.full_name == github.repository &&
129+
(
130+
steps.changed-files.outputs.base_dockerfile_any_changed == 'true' ||
131+
(
132+
matrix.pipeline == 'liveportrait' &&
133+
steps.changed-files.outputs.liveportrait_any_changed == 'true'
134+
)
135+
)
136+
)
137+
with:
138+
context: "{{defaultContext}}:runner"
139+
platforms: linux/amd64
140+
push: ${{ github.event_name != 'pull_request' }}
141+
tags: livepeer/ai-runner:live-base-${{ matrix.pipeline }}
142+
file: docker/Dockerfile.live-base-${{ matrix.pipeline }}
143+
build-args: |
144+
PIPELINE=${{ matrix.pipeline }}
145+
cache-from: type=registry,ref=livepeerci/build:cache
146+
cache-to: type=registry,ref=livepeerci/build:cache,mode=max
147+
148+
- name: Extract metadata for app image
149+
id: meta
150+
uses: docker/metadata-action@v5
151+
with:
152+
images: livepeer/ai-runner
153+
tags: |
154+
type=raw,value=live-app-${{ matrix.pipeline }}
155+
type=sha,prefix=live-app-${{ matrix.pipeline }}-
156+
type=ref,event=pr,prefix=live-app-${{ matrix.pipeline }}-
157+
type=ref,event=tag,prefix=live-app-${{ matrix.pipeline }}-
158+
type=raw,value=latest,enable={{is_default_branch}},prefix=live-app-${{ matrix.pipeline }}-
159+
160+
- name: Build and push pipeline app image
161+
uses: docker/build-push-action@v5
162+
with:
163+
context: "{{defaultContext}}:runner"
164+
platforms: linux/amd64
165+
push: ${{ github.event_name != 'pull_request' }}
166+
tags: ${{ steps.meta.outputs.tags }}
167+
file: docker/Dockerfile.live-app__PIPELINE__
168+
build-args: |
169+
PIPELINE=${{ matrix.pipeline }}
170+
cache-from: type=registry,ref=livepeerci/build:cache
171+
cache-to: type=registry,ref=livepeerci/build:cache,mode=max
172+
173+
build-noop:
174+
name: Build pipeline image (noop)
175+
needs: build-common-base
176+
runs-on: ubuntu-20.04
177+
permissions:
178+
pull-requests: read
179+
steps:
180+
- name: Check out code
181+
uses: actions/[email protected]
182+
with:
183+
fetch-depth: 50
184+
ref: ${{ github.event.pull_request.head.sha }}
185+
186+
- name: Get changed files
187+
id: changed-files
188+
uses: tj-actions/changed-files@v45
189+
with:
190+
files: |
191+
runner/docker/Dockerfile.live-app-noop
192+
runner/app/**
193+
194+
- name: Check if build needed
195+
id: check_build
196+
if: |
197+
github.event_name == 'workflow_dispatch' ||
198+
github.event_name == 'push' ||
199+
(
200+
github.event_name == 'pull_request' &&
201+
github.event.pull_request.head.repo.full_name == github.repository &&
202+
steps.changed-files.outputs.any_changed == 'true'
203+
)
204+
run: echo "should_build=true" >> $GITHUB_OUTPUT
205+
206+
- name: Cleanup hosted runner
207+
uses: ./.github/actions/cleanup-runner
208+
if: steps.check_build.outputs.should_build == 'true'
209+
210+
- name: Set up Docker Buildx
211+
uses: docker/setup-buildx-action@v3
212+
213+
- name: Login to DockerHub
214+
uses: docker/login-action@v3
215+
with:
216+
username: ${{ secrets.CI_DOCKERHUB_USERNAME }}
217+
password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
218+
219+
- name: Extract metadata for Docker
220+
id: meta
221+
uses: docker/metadata-action@v5
222+
with:
223+
images: livepeer/ai-runner
224+
tags: |
225+
type=raw,value=live-app-noop
226+
type=sha,prefix=live-app-noop-
227+
type=ref,event=pr,prefix=live-app-noop-
228+
type=ref,event=tag,prefix=live-app-noop-
229+
type=raw,value=latest,enable={{is_default_branch}},prefix=live-app-noop-
230+
231+
- name: Build and push noop image
232+
uses: docker/build-push-action@v5
233+
if: steps.check_build.outputs.should_build == 'true'
234+
with:
235+
context: "{{defaultContext}}:runner"
236+
platforms: linux/amd64
237+
push: ${{ github.event_name != 'pull_request' }}
238+
tags: ${{ steps.meta.outputs.tags }}
239+
file: docker/Dockerfile.live-app-noop
240+
cache-from: type=registry,ref=livepeerci/build:cache
241+
cache-to: type=registry,ref=livepeerci/build:cache,mode=max

.github/workflows/ai-runner-pipelines-docker.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-20.04
3030
strategy:
3131
matrix:
32-
dockerfile:
32+
dockerfile:
3333
- docker/Dockerfile.segment_anything_2
3434
- docker/Dockerfile.text_to_speech
3535
steps:
@@ -42,13 +42,7 @@ jobs:
4242
ref: ${{ github.event.pull_request.head.sha }}
4343

4444
- name: Cleanup hosted runner
45-
run: |
46-
sudo apt purge -yqq dotnet-* mono-* llvm-* libllvm* powershell* openjdk-* \
47-
temurin-* mongodb-* firefox mysql-* \
48-
hhvm google-chrome-stable \
49-
libgl1-mesa-dri microsoft-edge-stable azure-cli || true
50-
sudo apt autoremove -y
51-
sudo rm -rf /usr/share/dotnet /usr/local/lib/android
45+
uses: ./.github/actions/cleanup-runner
5246

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

runner/app/live/infer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ async def start_control_subscriber(handler: PipelineStreamer, control_url: str):
100100
"--publish-url", type=str, required=True, help="URL to publish output frames (trickle). For zeromq this is the output socket address"
101101
)
102102
parser.add_argument(
103-
"--control-url", type=str, help="URL to subscribe for Control API JSON messages"
103+
"--control-url", type=str, help="URL to subscribe for Control API JSON messages to update inference params"
104104
)
105105
parser.add_argument(
106106
"--input-timeout",

runner/docker/Dockerfile.live-base-liveportrait

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ARG BASE_IMAGE=livepeer/ai-runner:live-base
22
FROM ${BASE_IMAGE}
33

44
# Download and install the NVIDIA TensorRT repository local deb
5-
RUN wget https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/secure/8.6.1/local_repos/nv-tensorrt-local-repo-ubuntu2204-8.6.1-cuda-12.0_1.0-1_amd64.deb && \
5+
RUN wget --progress=dot:mega https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/secure/8.6.1/local_repos/nv-tensorrt-local-repo-ubuntu2204-8.6.1-cuda-12.0_1.0-1_amd64.deb && \
66
dpkg -i nv-tensorrt-local-repo-ubuntu2204-8.6.1-cuda-12.0_1.0-1_amd64.deb && \
77
cp /var/nv-tensorrt-local-repo-ubuntu2204-8.6.1-cuda-12.0/*-keyring.gpg /usr/share/keyrings/ && \
88
rm nv-tensorrt-local-repo-ubuntu2204-8.6.1-cuda-12.0_1.0-1_amd64.deb
@@ -58,7 +58,7 @@ COPY images/flame-serious.jpg \
5858
COPY requirements-liveportrait.txt requirements.txt
5959
RUN pip install --no-cache-dir -r requirements.txt
6060

61-
# TODO: Setup dependencies for animal models
61+
# TODO: Setup dependencies for animal models (needs some custom deps detected on runtime which are not on pypi)
6262

6363
WORKDIR /app
6464

runner/run-lv2v.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ PORT=${4:-9000}
1313

1414
# Build images, this will be quick if everything is cached
1515
docker build -t livepeer/ai-runner:live-base -f docker/Dockerfile.live-base .
16-
docker build -t livepeer/ai-runner:live-base-${PIPELINE} -f docker/Dockerfile.live-base-${PIPELINE} .
17-
docker build -t livepeer/ai-runner:live-app-${PIPELINE} -f docker/Dockerfile.live-app__PIPELINE__ --build-arg PIPELINE=${PIPELINE} .
16+
if [ "${PIPELINE}" = "noop" ]; then
17+
docker build -t livepeer/ai-runner:live-app-noop -f docker/Dockerfile.live-app-noop .
18+
else
19+
docker build -t livepeer/ai-runner:live-base-${PIPELINE} -f docker/Dockerfile.live-base-${PIPELINE} .
20+
docker build -t livepeer/ai-runner:live-app-${PIPELINE} -f docker/Dockerfile.live-app__PIPELINE__ --build-arg PIPELINE=${PIPELINE} .
21+
fi
1822

1923
CONTAINER_NAME=live-video-to-video-${PIPELINE}
2024
docker run -it --rm --name ${CONTAINER_NAME} \

0 commit comments

Comments
 (0)