From 77343999f6912393c7edeae2b9be03faef3c4234 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Fri, 5 Jul 2024 15:24:55 +0200 Subject: [PATCH] update docker --- .gitignore | 1 + docker/docker-compose.yml | 6 + docker/ffmpeg.Dockerfile | 158 ++++++++++++++++++++++++ docker/fromSource.Dockerfile | 161 ------------------------- docker/nonfree.Dockerfile | 29 +++++ docker/nvidia-centos7.Dockerfile | 112 ----------------- docker/nvidia.Dockerfile | 198 +++++++++++++++++++++++++++++++ 7 files changed, 392 insertions(+), 273 deletions(-) create mode 100644 docker/ffmpeg.Dockerfile delete mode 100644 docker/fromSource.Dockerfile create mode 100644 docker/nonfree.Dockerfile delete mode 100644 docker/nvidia-centos7.Dockerfile create mode 100644 docker/nvidia.Dockerfile diff --git a/.gitignore b/.gitignore index d8777381..6aa3fdbb 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ ffplayout.1.gz /assets/*.db* /dist/ +data/ /public/ tmp/ assets/playlist_template.json diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 296ce389..2def622b 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -6,5 +6,11 @@ services: build: context: . dockerfile: ./Dockerfile + volumes: + - ./data/db:/db + - ./data/storage:/tv-media + - ./data/playlists:/playlists + - ./data/logging:/logging + - ./data/hls:/hls ports: - '8787:8787' diff --git a/docker/ffmpeg.Dockerfile b/docker/ffmpeg.Dockerfile new file mode 100644 index 00000000..8ae5ff44 --- /dev/null +++ b/docker/ffmpeg.Dockerfile @@ -0,0 +1,158 @@ +FROM alpine:latest as builder + +ENV EXTRA_CFLAGS=-march=generic \ + LOCALBUILDDIR=/tmp/build \ + LOCALDESTDIR=/tmp/local \ + PKG_CONFIG="pkg-config --static" \ + PKG_CONFIG_PATH=/tmp/local/lib/pkgconfig \ + CPPFLAGS="-I/tmp/local/include -O3 -fno-strict-overflow -fstack-protector-all -fPIC" \ + CFLAGS="-I/tmp/local/include -O3 -fno-strict-overflow -fstack-protector-all -fPIC" \ + CXXFLAGS="-I/tmp/local/include -O2 -fPIC" \ + LDFLAGS="-L/tmp/local/lib -pipe -Wl,-z,relro,-z,now -static" \ + CC=clang + +RUN apk add --no-cache \ + clang \ + glib-dev glib-static \ + coreutils \ + autoconf \ + automake \ + build-base \ + cmake \ + git \ + libtool \ + nasm \ + pkgconfig \ + yasm \ + wget \ + curl \ + ninja-build \ + meson \ + cargo cargo-c \ + diffutils \ + bash + +RUN apk add --no-cache \ + zlib-dev zlib-static \ + bzip2-dev bzip2-static \ + expat-dev expat-static \ + libxml2-dev libxml2-static \ + fontconfig-dev fontconfig-static \ + freetype freetype-dev freetype-static \ + fribidi-dev fribidi-static \ + harfbuzz-dev harfbuzz-static \ + graphite2-static \ + numactl-dev \ + brotli-dev brotli-static \ + soxr-dev soxr-static \ + libjpeg-turbo libjpeg-turbo-dev \ + libpng-dev libpng-static \ + xvidcore-dev xvidcore-static \ + libsodium-dev libsodium-static \ + zeromq-dev libzmq-static \ + openssl-dev openssl-libs-static + +WORKDIR /tmp +RUN git clone --depth 1 "https://github.com/libass/libass.git" && cd libass && \ + ./autogen.sh && \ + ./configure --prefix="$LOCALDESTDIR" --enable-shared=no && \ + make -j $(nproc) && \ + make install + +RUN git clone --depth 1 "https://github.com/mstorsjo/fdk-aac" && cd fdk-aac && \ + ./autogen.sh && \ + ./configure --prefix="$LOCALDESTDIR" --enable-shared=no && \ + make -j $(nproc) && \ + make install + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "lame-3.100.tar.gz" "https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz" && \ + tar xf "lame-3.100.tar.gz" && \ + cd "lame-3.100" && \ + ./configure --prefix="$LOCALDESTDIR" --enable-expopt=full --enable-shared=no && \ + make -j $(nproc) && \ + make install + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "opus-1.4.tar.gz" "https://ftp.osuosl.org/pub/xiph/releases/opus/opus-1.4.tar.gz" && \ + tar xf "opus-1.4.tar.gz" && \ + cd "opus-1.4" && \ + ./configure --prefix="$LOCALDESTDIR" --enable-shared=no --enable-static --disable-doc && \ + make -j $(nproc) && \ + make install + +RUN git clone --depth 1 "https://github.com/Haivision/srt.git" && cd srt && \ + mkdir build && \ + cd build && \ + cmake .. -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DENABLE_SHARED:BOOLEAN=OFF -DOPENSSL_USE_STATIC_LIBS=ON -DUSE_STATIC_LIBSTDCXX:BOOLEAN=ON -DENABLE_CXX11:BOOLEAN=ON -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" && \ + make -j $(nproc) && \ + make install + +RUN git clone "https://github.com/webmproject/libvpx.git" && cd libvpx && \ + ./configure --prefix="$LOCALDESTDIR" --disable-shared --enable-static --disable-unit-tests --disable-docs --enable-postproc --enable-vp9-postproc --enable-runtime-cpu-detect && \ + make -j $(nproc) && \ + make install + +RUN git clone "https://code.videolan.org/videolan/x264" && cd x264 && \ + ./configure --prefix="$LOCALDESTDIR" --enable-static && \ + make -j $(nproc) && \ + make install + +RUN git clone "https://bitbucket.org/multicoreware/x265_git.git" && cd x265_git/build && \ + cmake ../source -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DENABLE_SHARED:BOOLEAN=OFF -DCMAKE_CXX_FLAGS_RELEASE:STRING="-O3 -DNDEBUG $CXXFLAGS" && \ + make -j $(nproc) && \ + make install + +RUN git clone "https://github.com/xiph/rav1e.git" && cd rav1e && \ + RUSTFLAGS="-C target-feature=+crt-static" cargo cinstall --release --jobs $(nproc) --prefix=$LOCALDESTDIR --libdir=$LOCALDESTDIR/lib --includedir=$LOCALDESTDIR/include + +RUN git clone --depth 1 "https://gitlab.com/AOMediaCodec/SVT-AV1.git" && cd SVT-AV1/Build && \ + cmake .. -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" && \ + make -j $(nproc) && \ + make install + +RUN git clone --depth 1 "https://code.videolan.org/videolan/dav1d.git" && cd dav1d && \ + mkdir build && cd build && \ + meson setup -Denable_tools=false -Denable_tests=false --default-library=static .. --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib" && \ + ninja && \ + ninja install + +RUN git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git && cd ffmpeg && \ + sed -i 's/add_ldexeflags -fPIE -pie/add_ldexeflags -fPIE -static-pie/' configure && \ + ./configure \ + --pkg-config-flags=--static \ + --extra-cflags="-fopenmp -DZMG_STATIC" \ + --extra-ldflags="-fopenmp -Wl,--copy-dt-needed-entries -Wl,--allow-multiple-definition" \ + --enable-runtime-cpudetect \ + --prefix=/usr/local \ + --disable-debug \ + --disable-doc \ + --disable-ffplay \ + --disable-shared \ + --enable-gpl \ + --enable-version3 \ + --enable-nonfree \ + --enable-small \ + --enable-static \ + --enable-libass \ + --enable-fontconfig \ + --enable-libfdk-aac \ + --enable-libfribidi \ + --enable-libfreetype \ + --enable-libharfbuzz \ + --enable-libmp3lame \ + --enable-libopus \ + --enable-libsoxr \ + --enable-libsrt \ + --enable-libvpx \ + --enable-libx264 \ + --enable-libx265 \ + --enable-libzmq \ + --enable-nonfree \ + --enable-openssl \ + --enable-libsvtav1 \ + --enable-librav1e \ + --enable-libdav1d \ + --enable-libxvid && \ + make -j $(nproc) && \ + make install + +RUN strip /usr/local/bin/ffmpeg /usr/local/bin/ffprobe diff --git a/docker/fromSource.Dockerfile b/docker/fromSource.Dockerfile deleted file mode 100644 index 59a27ea7..00000000 --- a/docker/fromSource.Dockerfile +++ /dev/null @@ -1,161 +0,0 @@ -FROM almalinux:9 AS base - -ENV container docker - -RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \ - systemd-tmpfiles-setup.service ] || rm -f $i; done); \ - rm -f /lib/systemd/system/multi-user.target.wants/*; \ - rm -f /etc/systemd/system/*.wants/*; \ - rm -f /lib/systemd/system/local-fs.target.wants/*; \ - rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ - rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ - rm -f /lib/systemd/system/basic.target.wants/*; \ - rm -f /lib/systemd/system/anaconda.target.wants/* - -FROM base AS build - -WORKDIR /tmp/workdir - -ENV SRC=/usr/local \ - BUILD=/tmp/build - -ARG LD_LIBRARY_PATH=/opt/ffmpeg/lib -ARG PKG_CONFIG_PATH="/opt/ffmpeg/share/pkgconfig:/opt/ffmpeg/lib/pkgconfig:/opt/ffmpeg/lib64/pkgconfig:/lib64/pkgconfig" -ARG LOCALDESTDIR=/opt/ffmpeg -ARG LD_LIBRARY_PATH="/opt/ffmpeg/lib:/opt/ffmpeg/lib64" - -RUN \ - buildDeps="bzip2 gperf which libticonv autoconf automake cmake diffutils file gcc \ - ninja-build wget nasm gcc-c++ git libtool make perl yasm meson x264-devel zlib-devel \ - expat-devel fontconfig-devel libxml2-devel lame-devel libpng-devel numactl-devel \ - fribidi-devel zeromq-devel freetype-devel opus-devel libass-devel openssl-devel" && \ - echo "${SRC}/lib" > /etc/ld.so.conf.d/libc.conf && \ - dnf install -y epel-release && \ - dnf install -y 'dnf-command(config-manager)' && \ - dnf config-manager --set-enabled crb && \ - dnf install -y --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm && \ - dnf install -y --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm && \ - dnf install -y ${buildDeps} && \ - mkdir -p ${BUILD} - -RUN \ - cd ${BUILD} && \ - git clone --depth 1 "https://github.com/Haivision/srt.git" && \ - cd srt && \ - mkdir build && \ - cd build && \ - cmake .. -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DENABLE_SHARED:BOOLEAN=OFF -DUSE_STATIC_LIBSTDCXX:BOOLEAN=ON \ - -DENABLE_CXX11:BOOLEAN=OFF -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" && \ - make -j $(nproc | awk '{print $1 / 2}') && \ - make install - -RUN \ - cd ${BUILD} && \ - git clone --depth 1 "https://code.videolan.org/rist/librist.git" && \ - cd librist && \ - mkdir build && \ - cd build && \ - meson setup --default-library=static --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib" .. && \ - ninja && \ - ninja install - -RUN \ - cd ${BUILD} && \ - git clone --depth 1 "https://github.com/mstorsjo/fdk-aac" && \ - cd fdk-aac && \ - ./autogen.sh && \ - ./configure --prefix="$LOCALDESTDIR" --enable-shared=no && \ - make -j $(nproc | awk '{print $1 / 2}') && \ - make install - -RUN \ - cd ${BUILD} && \ - git clone --depth 1 "https://gitlab.com/AOMediaCodec/SVT-AV1.git" && \ - cd SVT-AV1/Build && \ - rm -rf * && \ - cmake .. -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" && \ - make -j $(nproc | awk '{print $1 / 2}') && \ - make install - -RUN \ - cd ${BUILD} && \ - git clone --depth 1 "https://code.videolan.org/videolan/dav1d.git" && \ - cd dav1d && \ - mkdir build && \ - cd build && \ - meson setup -Denable_tools=false -Denable_tests=false --default-library=static .. --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib" && \ - ninja && \ - ninja install - -RUN \ - cd ${BUILD} && \ - git clone "https://github.com/webmproject/libvpx.git" && \ - cd libvpx && \ - ./configure --prefix="$LOCALDESTDIR" --disable-shared --enable-static --disable-unit-tests --disable-docs --enable-postproc --enable-vp9-postproc --enable-runtime-cpu-detect && \ - make -j $(nproc | awk '{print $1 / 2}') && \ - make install - -RUN \ - cd ${BUILD} && \ - git clone "https://bitbucket.org/multicoreware/x265_git.git" x265 && \ - cd x265/build && \ - rm -rf * && \ - cmake ../source -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DENABLE_SHARED:BOOLEAN=OFF -DCMAKE_CXX_FLAGS_RELEASE:STRING="-O3 -DNDEBUG" && \ - make -j $(nproc | awk '{print $1 / 2}') && \ - make install - -RUN \ - cd ${BUILD} && \ - wget "https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2" && \ - tar xfvj ffmpeg-snapshot.tar.bz2 && \ - rm -rf ffmpeg-snapshot.tar.bz2 && \ - cd ffmpeg && \ - ./configure --prefix="$LOCALDESTDIR" --enable-pthreads --extra-libs=-lpthread \ - --disable-debug --disable-shared --disable-doc --enable-gpl --enable-version3 --pkg-config-flags=--static \ - --enable-nonfree --enable-runtime-cpudetect --enable-fontconfig \ - --enable-openssl --enable-libass --enable-libfdk-aac --enable-libfreetype \ - --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libvpx --enable-librist \ - --enable-libsrt --enable-libx264 --enable-libx265 --enable-libzmq --enable-libsvtav1 --enable-libdav1d && \ - make -j $(nproc | awk '{print $1 / 2}') && \ - make install - -RUN \ - cd / && \ - cp /opt/ffmpeg/bin/ff* /usr/local/bin/ && \ - rm -rf $BUILD $LOCALDESTDIR && \ - dnf -y remove autoconf automake cmake diffutils file gcc ninja-build nasm gcc-c++ git libtool make perl yasm meson \ - x264-devel zlib-devel expat-devel fontconfig-devel libxml2-devel lame-devel libpng-devel numactl-devel \ - fribidi-devel zeromq-devel freetype-devel opus-devel libass-devel openssl-devel && \ - dnf autoremove -y && \ - dnf clean all - -FROM base - -ARG FFPLAYOUT_VERSION=0.22.0 - -ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib - -COPY --from=build /usr/local/ /usr/local/ - -ADD ./overide.conf /etc/systemd/system/ffplayout.service.d/overide.conf - -RUN \ - dnf update -y \ - dnf install -y epel-release && \ - dnf install -y 'dnf-command(config-manager)' && \ - dnf config-manager --set-enabled crb && \ - dnf install -y --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm && \ - dnf install -y --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm && \ - dnf install -y wget dejavu-sans-fonts sudo x264-libs fontconfig lame libpng numactl fribidi zeromq freetype opus libass && \ - wget -q -O /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm "https://github.com/ffplayout/ffplayout/releases/download/v${FFPLAYOUT_VERSION}/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm" && \ - dnf install -y /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm && \ - dnf clean all && \ - rm /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm && \ - mkdir -p /home/ffpu && chown -R ffpu: /home/ffpu && \ - systemctl enable ffplayout && \ - ffplayout -u admin -p admin -m contact@example.com - -EXPOSE 8787 - -CMD ["/usr/sbin/init"] diff --git a/docker/nonfree.Dockerfile b/docker/nonfree.Dockerfile new file mode 100644 index 00000000..5f1104c2 --- /dev/null +++ b/docker/nonfree.Dockerfile @@ -0,0 +1,29 @@ +FROM alpine:latest + +ARG FFPLAYOUT_VERSION=0.24.0-alpha1 +ARG SHARED_STORAGE=false + +ENV DB=/db +ENV SHARED_STORAGE=${SHARED_STORAGE} + +COPY --from=ffmpeg-build /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg +COPY --from=ffmpeg-build /usr/local/bin/ffprobe /usr/local/bin/ffprobe +COPY README.md ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.* /tmp/ + +RUN apk update && \ + apk upgrade && \ + apk add --no-cache sqlite font-dejavu + +RUN [[ -f "/tmp/ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.gz" ]] || \ + wget -q "https://github.com/ffplayout/ffplayout/releases/download/v${FFPLAYOUT_VERSION}/ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.gz" -P /tmp/ && \ + cd /tmp && \ + tar xf "ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.gz" && \ + cp ffplayout /usr/bin/ && \ + rm -rf /tmp/* && \ + mkdir ${DB} + +RUN ffplayout -u admin -p admin -m contact@example.com --storage-path "/tv-media" --playlist-path "/playlists" --hls-path "/hls" --log-path "/logging" + +EXPOSE 8787 + +CMD ["/usr/bin/ffplayout", "-l", "0.0.0.0:8787"] diff --git a/docker/nvidia-centos7.Dockerfile b/docker/nvidia-centos7.Dockerfile deleted file mode 100644 index f1fd376b..00000000 --- a/docker/nvidia-centos7.Dockerfile +++ /dev/null @@ -1,112 +0,0 @@ -FROM nvidia/cuda:12.0.1-cudnn8-runtime-centos7 - -ENV FFPLAYOUT_VERSION=0.22.0 -ENV NVIDIA_VISIBLE_DEVICES all -ENV NVIDIA_DRIVER_CAPABILITIES compute,video,utility - -ENV NVCODEC_VERSION 8.2.15.6 -ENV FFMPEG_VERSION 5.1.2 -ENV X264_VERSION=20191217-2245 -ENV NASM_VERSION=2.14.02 -ENV FDKAAC_VERSION=0.1.5 -RUN yum install -y wget - -RUN buildDeps="autoconf \ - automake \ - bzip2 \ - cmake3 \ - diffutils \ - expat-devel \ - file \ - gcc \ - gcc-c++ \ - git \ - gperf \ - libtool \ - make \ - perl \ - python3 \ - openssl-devel \ - tar \ - yasm \ - which \ - zlib-devel" && \ - echo "${SRC}/lib" > /etc/ld.so.conf.d/libc.conf && \ - yum --enablerepo=extras install -y epel-release && \ - yum --enablerepo=epel install -y ${buildDeps} && \ - alternatives --install /usr/bin/cmake cmake /usr/bin/cmake3 0 && \ - # Install the tools required to build nasm 2.14.02 \ - nasmDeps="asciidoc \ - perl-Font-TTF \ - perl-Sort-Versions \ - xmlto" && \ - yum --enablerepo=epel install -y ${nasmDeps} -RUN curl -fsSLO https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/nasm-$NASM_VERSION.tar.bz2 \ - && tar -xjf nasm-$NASM_VERSION.tar.bz2 \ - && cd nasm-$NASM_VERSION \ - && ./autogen.sh \ - && ./configure \ - && make -j$(nproc) \ - && make install -RUN \ - DIR=/tmp/x264 && \ - mkdir -p ${DIR} && \ - cd ${DIR} && yum install -y wget && \ - wget https://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20191217-2245.tar.bz2 && \ - tar -xjf x264-snapshot-${X264_VERSION}.tar.bz2 && cd x264-snapshot-${X264_VERSION} && \ - ./configure --enable-shared --enable-pic --disable-cli && \ - make -j $(nproc | awk '{print $1 / 2}') && \ - make install - -### fdk-aac https://github.com/mstorsjo/fdk-aac -RUN \ - DIR=/tmp/fdk-aac && \ - mkdir -p ${DIR} && \ - cd ${DIR} && \ - curl -sL https://github.com/mstorsjo/fdk-aac/archive/v${FDKAAC_VERSION}.tar.gz | \ - tar -zx --strip-components=1 && \ - autoreconf -fiv && \ - ./configure --enable-shared --datadir="${DIR}" && \ - make -j $(nproc | awk '{print $1 / 2}') && \ - make install && \ - rm -rf ${DIR} - -RUN git clone --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers \ - && cd nv-codec-headers \ - && make install -ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig -RUN curl -fsSLO https://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 \ - && tar -xjf ffmpeg-$FFMPEG_VERSION.tar.bz2 \ - && cd ffmpeg-$FFMPEG_VERSION \ - && ./configure --enable-nvenc --enable-libx264 --enable-gpl --enable-libfdk_aac --enable-nonfree --enable-postproc --enable-shared --enable-version3 \ - && make -j$(nproc) \ - && make install - -RUN yum -y install systemd vim pico; yum clean all; \ -(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ -rm -f /lib/systemd/system/multi-user.target.wants/*;\ -rm -f /etc/systemd/system/*.wants/*;\ -rm -f /lib/systemd/system/local-fs.target.wants/*; \ -rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ -rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ -rm -f /lib/systemd/system/basic.target.wants/*;\ -rm -f /lib/systemd/system/anaconda.target.wants/*; -RUN yum -y install net-tools openssh-server -RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config - -RUN yum update -y \ - && yum install -y dejavu-sans-fonts sudo wget \ - && wget -q -O /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm "https://github.com/ffplayout/ffplayout/releases/download/v${FFPLAYOUT_VERSION}/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm" \ - && yum install -y /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm \ - && yum clean all \ - && echo 'Docker!' | passwd --stdin root \ - && rm /tmp/ffplayout-${FFPLAYOUT_VERSION}-1.x86_64.rpm \ - && mkdir -p /home/ffpu && chown -R ffpu: /home/ffpu \ - && systemctl enable ffplayout - -EXPOSE 8787 -RUN echo "/usr/local/lib" >> /etc/ld.so.conf.d/nvidia.conf -RUN echo "/usr/local/cuda/compat/" >> /etc/ld.so.conf.d/nvidia.conf - -VOLUME [ "/tmp", "/run", "/run/lock", "/etc/ffplayout", "/usr/share/ffplayout" ,"/var/lib/ffplayout" ] -CMD ["/usr/sbin/init"] diff --git a/docker/nvidia.Dockerfile b/docker/nvidia.Dockerfile new file mode 100644 index 00000000..fb2a1ab5 --- /dev/null +++ b/docker/nvidia.Dockerfile @@ -0,0 +1,198 @@ +FROM nvidia/cuda:12.5.0-runtime-rockylinux9 + +ARG FFPLAYOUT_VERSION=0.24.0-alpha1 +ARG SHARED_STORAGE=false + +ENV DB=/db +ENV SHARED_STORAGE=${SHARED_STORAGE} +ENV EXTRA_CFLAGS=-march=generic \ + LOCALBUILDDIR=/tmp/build \ + LOCALDESTDIR=/tmp/local \ + PKG_CONFIG="pkg-config --static" \ + PKG_CONFIG_PATH="/usr/lib64/pkgconfig/:/tmp/local/lib/pkgconfig" \ + CPPFLAGS="-I/tmp/local/include -O3 -fno-strict-overflow -fstack-protector-all -fPIC" \ + CFLAGS="-I/tmp/local/include -O3 -fno-strict-overflow -fstack-protector-all -fPIC" \ + CXXFLAGS="-I/tmp/local/include -O2 -fPIC" \ + LDFLAGS="-L/tmp/local/lib -pipe -Wl,-z,relro,-z,now -static" \ + CC=clang + +COPY README.md ffplayout-v${FFPLAYOUT_VERSION}_x86_64-unknown-linux-musl.tar.* /tmp/ + +RUN dnf clean all -y && \ + dnf makecache --refresh && \ + dnf install -y epel-release && \ + dnf config-manager --set-enabled crb + +RUN dnf install -y which sqlite libstdc++-static libtool autoconf clang \ + cmake ninja-build cargo ragel meson git pkgconfig bzip2 \ + python3-devel gperf perl glibc-static binutils-devel \ + nasm rsync + +WORKDIR /tmp + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "zlib-1.3.1.tar.gz" "https://zlib.net/zlib-1.3.1.tar.gz" && \ + tar xf "zlib-1.3.1.tar.gz" && \ + cd "zlib-1.3.1" && \ + ./configure --prefix="$LOCALDESTDIR" --static && \ + make -j $(nproc) && \ + make install + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "openssl-1.1.1u.tar.gz" "https://www.openssl.org/source/openssl-1.1.1u.tar.gz" && \ + tar xf "openssl-1.1.1u.tar.gz" && \ + cd "openssl-1.1.1u" && \ + ./Configure --prefix=$LOCALDESTDIR --openssldir=$LOCALDESTDIR linux-x86_64 --libdir="$LOCALDESTDIR/lib" no-shared enable-camellia enable-idea enable-mdc2 enable-rfc3779 -static-libstdc++ -static-libgcc && \ + make depend all && \ + make install_sw + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "bzip2-1.0.8.tar.gz" "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz" && \ + tar xf "bzip2-1.0.8.tar.gz" && \ + cd "bzip2-1.0.8" && \ + make install PREFIX="$LOCALDESTDIR" + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "libpng-1.6.40.tar.gz" "http://prdownloads.sourceforge.net/libpng/libpng-1.6.40.tar.gz" && \ + tar xf "libpng-1.6.40.tar.gz" && \ + cd "libpng-1.6.40" && \ + ./configure --prefix="$LOCALDESTDIR" --disable-shared && \ + make -j $(nproc) && \ + make install + +RUN git clone --depth 1 "https://github.com/fribidi/fribidi.git" && cd fribidi && \ + ./autogen.sh && \ + ./configure --prefix="$LOCALDESTDIR" --enable-shared=no && \ + make -j $(nproc) 2>/dev/null || true && \ + make install + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "expat-2.5.0.tar.bz2" "https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.bz2" && \ + tar xf "expat-2.5.0.tar.bz2" && \ + cd "expat-2.5.0" && \ + ./configure --prefix="$LOCALDESTDIR" --enable-shared=no --without-docbook && \ + make -j $(nproc) && \ + make install + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "freetype-2.13.1.tar.gz" "https://sourceforge.net/projects/freetype/files/freetype2/2.13.1/freetype-2.13.1.tar.gz" && \ + tar xf "freetype-2.13.1.tar.gz" && \ + cd "freetype-2.13.1" && \ + ./configure --prefix="$LOCALDESTDIR" --disable-shared --with-harfbuzz=no && \ + make -j $(nproc) && \ + make install + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "fontconfig-2.14.2.tar.gz" "https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.14.2.tar.gz" && \ + tar xf "fontconfig-2.14.2.tar.gz" && \ + cd "fontconfig-2.14.2" && \ + ./configure --prefix="$LOCALDESTDIR" --enable-shared=no && \ + make -j $(nproc) && \ + make install && \ + cp fontconfig.pc "$LOCALDESTDIR/lib/pkgconfig/" + +RUN git clone --depth 1 "https://github.com/harfbuzz/harfbuzz.git" && cd harfbuzz && \ + mkdir build && cd build && \ + meson setup -Denable_tools=false --default-library=static .. --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib" && \ + ninja && \ + ninja install + +RUN git clone --depth 1 "https://github.com/zeromq/libzmq.git" && cd libzmq && \ + ./autogen.sh && \ + ./configure --prefix="$LOCALDESTDIR" --enable-static --disable-shared && \ + make -j $(nproc) && \ + make install + +RUN git clone --depth 1 "https://github.com/libass/libass.git" && cd libass && \ + ./autogen.sh && \ + ./configure --prefix="$LOCALDESTDIR" --enable-shared=no --disable-harfbuzz && \ + make -j $(nproc) && \ + make install + +RUN git clone --depth 1 "https://github.com/mstorsjo/fdk-aac" && cd fdk-aac && \ + ./autogen.sh && \ + ./configure --prefix="$LOCALDESTDIR" --enable-shared=no && \ + make -j $(nproc) && \ + make install + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "lame-3.100.tar.gz" "https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz" && \ + tar xf "lame-3.100.tar.gz" && \ + cd "lame-3.100" && \ + ./configure --prefix="$LOCALDESTDIR" --enable-expopt=full --enable-shared=no && \ + make -j $(nproc) && \ + make install + +RUN curl --retry 20 --retry-max-time 5 -L -k -f -w "%{response_code}" -o "opus-1.4.tar.gz" "https://ftp.osuosl.org/pub/xiph/releases/opus/opus-1.4.tar.gz" && \ + tar xf "opus-1.4.tar.gz" && \ + cd "opus-1.4" && \ + ./configure --prefix="$LOCALDESTDIR" --enable-shared=no --enable-static --disable-doc && \ + make -j $(nproc) && \ + make install + +RUN git clone --depth 1 "https://github.com/Haivision/srt.git" && cd srt && \ + mkdir build && \ + cd build && \ + cmake .. -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DENABLE_SHARED:BOOLEAN=OFF -DOPENSSL_USE_STATIC_LIBS=ON -DUSE_STATIC_LIBSTDCXX:BOOLEAN=ON -DENABLE_CXX11:BOOLEAN=ON -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DENABLE_APPS=0 -DENABLE_EXAMPLES=0 && \ + make -j $(nproc) && \ + make install + +RUN git clone "https://github.com/webmproject/libvpx.git" && cd libvpx && \ + ./configure --prefix="$LOCALDESTDIR" --as=nasm --disable-shared --enable-static --disable-unit-tests --disable-docs --enable-postproc --enable-vp9-postproc --enable-runtime-cpu-detect && \ + make -j $(nproc) && \ + make install + +RUN git clone "https://code.videolan.org/videolan/x264" && cd x264 && \ + ./configure --prefix="$LOCALDESTDIR" --enable-static && \ + make -j $(nproc) && \ + make install + +RUN git clone "https://bitbucket.org/multicoreware/x265_git.git" && cd x265_git/build && \ + cmake ../source -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DENABLE_SHARED:BOOLEAN=OFF -DCMAKE_CXX_FLAGS_RELEASE:STRING="-O3 -DNDEBUG $CXXFLAGS" && \ + make -j $(nproc) && \ + make install + +RUN git clone --depth 1 "https://gitlab.com/AOMediaCodec/SVT-AV1.git" && cd SVT-AV1/Build && \ + cmake .. -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" && \ + make -j $(nproc) && \ + make install + +RUN git clone --depth 1 "https://code.videolan.org/videolan/dav1d.git" && cd dav1d && \ + mkdir build && cd build && \ + meson setup -Denable_tools=false -Denable_tests=false --default-library=static .. --prefix "$LOCALDESTDIR" --libdir="$LOCALDESTDIR/lib" && \ + ninja && \ + ninja install + +RUN git clone --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers && cd nv-codec-headers && \ + make install PREFIX="$LOCALDESTDIR" + +RUN git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git && cd ffmpeg && \ + ./configure \ + --pkg-config-flags=--static \ + --extra-cflags="-fopenmp -DZMG_STATIC" \ + --extra-ldflags="-fopenmp -Wl,--copy-dt-needed-entries -Wl,--allow-multiple-definition" \ + --enable-runtime-cpudetect \ + --prefix=/usr/local \ + --disable-debug \ + --disable-doc \ + --disable-ffplay \ + --disable-shared \ + --enable-gpl \ + --enable-version3 \ + --enable-nonfree \ + --enable-small \ + --enable-static \ + --enable-libass \ + --enable-fontconfig \ + --enable-libfdk-aac \ + --enable-libfribidi \ + --enable-libfreetype \ + --enable-libharfbuzz \ + --enable-libmp3lame \ + --enable-libopus \ + --enable-libsrt \ + --enable-libvpx \ + --enable-libx264 \ + --enable-libx265 \ + --enable-libzmq \ + --enable-nonfree \ + --enable-openssl \ + --enable-libsvtav1 \ + --enable-libdav1d \ + --enable-nvenc && \ + make -j $(nproc) && \ + make install + +RUN strip /usr/local/bin/ffmpeg /usr/local/bin/ffprobe