wader / static-ffmpeg

Multi-arch docker image with ffmpeg/ffprobe binaries built as hardened static PIE binaries with no external dependencies
https://hub.docker.com/r/mwader/static-ffmpeg/
MIT License
264 stars 63 forks source link

Alternatives for more modular builds and patches support #216

Open wader opened 2 years ago

wader commented 2 years ago

Make it possible to enable/disable features when building. Alos thinking about adding some kind of optional patches support. Ex: put files in a patches directory and then will be applied in sorted order. Maybe patches/$FEATURE/001-fix.patch?

I think an ideal usage would be something like this:

# as before, all features enabled
docker build .

# all except rav1e
docker build --build-arg FEATURES="-rav1e" .

# no features at all
docker build --build-arg FEATURES="-all" .

# only libfdk-aac
docker build --build-arg FEATURES="-all +libfdk-aac" .

Issues to think about:

Possible implementation combining simple Dockerfile, cache friendly and no big shell script:

ARG FEATURES

# embed or COPY scripts for enable/enabled/download etc

# enable all dependencies and eval $FEATURES
RUN enabled \
  fontconfig \
  gray \
  ... \
  $FEATURES

...
# handle dependencies
RUN \
  enabled vorbis && enable ogg; \
  ...

...

libogg build here

...

# bump: vorbis /VORBIS_VERSION=([\d.]+)/ https://github.com/xiph/vorbis.git|*
# bump: vorbis after ./hashupdate Dockerfile VORBIS $LATEST
# bump: vorbis link "CHANGES" https://github.com/xiph/vorbis/blob/master/CHANGES
# bump: vorbis link "Source diff $CURRENT..$LATEST" https://github.com/xiph/vorbis/compare/v$CURRENT..v$LATEST
ARG VORBIS_VERSION=1.3.7
ARG VORBIS_URL="https://downloads.xiph.org/releases/vorbis/libvorbis-$VORBIS_VERSION.tar.gz"
ARG VORBIS_SHA256=0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab
RUN if enabled vorbis; then \
  download $DAV1D_URL $DAV1D_SHA256 && \
  add-version vorbis $VORBIS_VERSION && \
  ffmpeg-configure --enable-libvorbis && \
  cd libvorbis-* && ./configure --disable-shared --enable-static --disable-oggtest && \
  make -j$(nproc) install \
fi

A simple way to implement enable/enabled is to just use files in a directory, so enable would for +?name do touch /featurs/$1, for -name do rm /featurs/$1 and for -all do rm /features/*. add-version could just append to a JSON file. ffmpeg-configure just append to a file and download wrapper around wget and checksum check.

mathieu-aubin commented 2 years ago

did you read this -> https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/

and of so, is it relevant? not much time npw but i figured id input

this one too -> https://hub.docker.com/r/linuxserver/ffmpeg

wader commented 2 years ago

@mathieu-aubin hey, replied here https://github.com/wader/static-ffmpeg/issues/217#issuecomment-1172865260