Commit d7f43a66 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Replace apt-get ffmpeg with a cached static binary - real fix for CI speed

The Container Registry approach (build_ci_image) is reverted - confirmed via
job log that $CI_REGISTRY is empty on this self-hosted instance (Container
Registry isn't deployed here), so there was nowhere to push to.

Root cause confirmed from an actual job log: apt-get install ffmpeg alone
took 2min51s, unpacking/configuring 185 packages (video codecs, X11/Mesa/GL,
fonts, speech-recognition libs) that this project never uses - it's audio-
only. None of that is cacheable via apt itself.

Fix: download John Van Sickle's static ffmpeg build (verified genuinely
static via ldd - "not a dynamic executable", confirmed real mp3 encoding
works at 278x realtime) instead of apt-installing it, and cache the binary
itself via the existing cache: block so even the download only happens on
the first run. git is also dropped from the apt install list - confirmed
unused anywhere in app/test code (GitLab's own checkout doesn't use it).

Verified locally: full 104-test suite passes with *only* this static binary
on PATH (system ffmpeg hidden), matching what CI will have.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 715396bf
Pipeline #1015 failed with stage
in 38 seconds
stages:
- build
- test
- deploy
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
FFMPEG_CACHE_DIR: "$CI_PROJECT_DIR/.cache/ffmpeg-static"
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cache/pip/
# Manual only - builds and pushes the pre-baked test image (Dockerfile.ci) to this project's
# Container Registry. Run this by hand (Build > Pipelines > this pipeline > play button) once,
# and again whenever Dockerfile.ci's system deps change. Doesn't touch the test job below on
# its own - that's switched over separately once this is confirmed working, so a failure here
# (e.g. if this runner doesn't support Docker-in-Docker) can't break the normal pipeline.
build_ci_image:
stage: build
image: docker:24.0
services:
- docker:24.0-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script:
- docker build -t "$CI_REGISTRY_IMAGE/ci-test:latest" -f Dockerfile.ci .
- docker push "$CI_REGISTRY_IMAGE/ci-test:latest"
when: manual
only:
- dev
- main
- .cache/ffmpeg-static/
# Runs on every push to dev or main. No deploy here - just fast feedback while you're
# developing on dev, and a second confirmation right before deploy_prod fires on main.
......@@ -39,7 +18,20 @@ test:
stage: test
image: python:3.10-slim
before_script:
- apt-get update -qq && apt-get install -y -qq --no-install-recommends ffmpeg git libsndfile1
# apt's `ffmpeg` package drags in ~185 packages (video codecs, X11/Mesa, fonts, speech
# recognition libs) that took ~3min to unpack/configure on this runner, for functionality
# this project never uses (audio-only). A static, dependency-free ffmpeg build sidesteps
# apt/dpkg entirely - cached across runs so even the download only happens once. git isn't
# needed here at all (GitLab's own checkout doesn't use the job container's git).
- apt-get update -qq && apt-get install -y -qq --no-install-recommends libsndfile1 curl ca-certificates
- |
if [ ! -x "$FFMPEG_CACHE_DIR/ffmpeg" ]; then
mkdir -p "$FFMPEG_CACHE_DIR"
curl -sL https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o /tmp/ffmpeg.tar.xz
tar -xf /tmp/ffmpeg.tar.xz -C /tmp
cp /tmp/ffmpeg-*-amd64-static/ffmpeg /tmp/ffmpeg-*-amd64-static/ffprobe "$FFMPEG_CACHE_DIR/"
fi
cp "$FFMPEG_CACHE_DIR/ffmpeg" "$FFMPEG_CACHE_DIR/ffprobe" /usr/local/bin/
# No torch/demucs here on purpose - requirements-remix.txt (the heavy stem-separation
# model) is prod-only. Nothing in the test suite needs the real separator; see
# remix_engine.py's _get_separator() and requirements-remix.txt for why that's safe.
......
# Pre-baked CI test image - exists purely so the `test` job in .gitlab-ci.yml doesn't have to
# apt-get install ffmpeg (and its ~180-package dependency tree: video codecs, X11/Mesa/GL,
# fonts, speech-recognition libs, none of which this project uses) on every single push.
# Rebuild via the manual build_ci_image job whenever these system deps change.
FROM python:3.10-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg git libsndfile1 \
&& rm -rf /var/lib/apt/lists/*
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment