Skip to content

Commit

Permalink
Refactor Dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvino committed Jan 14, 2024
1 parent 2f4e011 commit 3132b1e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 34 deletions.
52 changes: 32 additions & 20 deletions Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
FROM DISTRO

# Docker build arguments
ARG SOURCE_DIR=/ffmpeg
ARG ARTIFACT_DIR=/dist

# Docker run environment
ENV DEB_BUILD_OPTIONS=noddebs
ENV DEBIAN_FRONTEND=noninteractive
ENV ARCH=BUILD_ARCHITECTURE
ENV GCC_VER=GCC_RELEASE_VERSION
ENV LLVM_VER=LLVM_RELEASE_VERSION
ENV SOURCE_DIR=/ffmpeg
ENV ARTIFACT_DIR=/dist
ENV TARGET_DIR=/usr/lib/jellyfin-ffmpeg
ENV DPKG_INSTALL_LIST=${SOURCE_DIR}/debian/jellyfin-ffmpeg6.install
ENV PATH=${TARGET_DIR}/bin:${PATH}
ENV PKG_CONFIG_PATH=${TARGET_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH}
ENV LD_LIBRARY_PATH=${TARGET_DIR}/lib:${TARGET_DIR}/lib/mfx:${TARGET_DIR}/lib/xorg:${LD_LIBRARY_PATH}
ENV LDFLAGS="-Wl,-rpath=${TARGET_DIR}/lib -L${TARGET_DIR}/lib"
ENV CXXFLAGS="-I${TARGET_DIR}/include $CXXFLAGS"
ENV CPPFLAGS="-I${TARGET_DIR}/include $CPPFLAGS"
ENV CFLAGS="-I${TARGET_DIR}/include $CFLAGS"
ENV DEBIAN_FRONTEND=noninteractive \
SOURCE_DIR=/ffmpeg \
ARTIFACT_DIR=/dist \
DEB_BUILD_OPTIONS=noddebs \
ARCH=BUILD_ARCHITECTURE \
GCC_VER=GCC_RELEASE_VERSION \
LLVM_VER=LLVM_RELEASE_VERSION \
TARGET_DIR=/usr/lib/jellyfin-ffmpeg \
DPKG_INSTALL_LIST=${SOURCE_DIR}/debian/jellyfin-ffmpeg6.install \
PATH=${TARGET_DIR}/bin:${PATH} \
PKG_CONFIG_PATH=${TARGET_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH} \
CFLAGS="-I${TARGET_DIR}/include $CFLAGS" \
CPPFLAGS="-I${TARGET_DIR}/include $CPPFLAGS" \
CXXFLAGS="-I${TARGET_DIR}/include $CXXFLAGS" \
LDFLAGS="-Wl,-rpath=${TARGET_DIR}/lib -L${TARGET_DIR}/lib" \
LD_LIBRARY_PATH=${TARGET_DIR}/lib:${TARGET_DIR}/lib/mfx:${TARGET_DIR}/lib/xorg:${LD_LIBRARY_PATH}

# Prepare Debian build environment
RUN apt-get update \
&& apt-get upgrade -y \
&& yes | apt-get install -y apt-transport-https curl ninja-build debhelper gnupg wget devscripts mmv equivs git nasm pkg-config subversion dh-autoreconf libpciaccess-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-present-dev libxcb-shm0-dev libxcb-sync-dev libxshmfence-dev libxext-dev libxfixes-dev libxcb1-dev libxrandr-dev libzstd-dev libelf-dev python3-pip zip unzip tar flex bison
&& apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
curl ninja-build debhelper gnupg wget devscripts \
mmv equivs git nasm pkg-config subversion dh-autoreconf \
libpciaccess-dev libwayland-dev libx11-dev libx11-xcb-dev \
libxcb-dri2-0-dev libxcb-dri3-dev libxcb-present-dev \
libxcb-shm0-dev libxcb-sync-dev libxshmfence-dev libxext-dev \
libxfixes-dev libxcb1-dev libxrandr-dev libzstd-dev \
libelf-dev python3-pip zip unzip tar flex bison \
&& apt-get clean autoclean -y \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*

# Install newer tools from pip3
RUN pip3 install $(pip3 help install | grep -o "\-\-break-system-packages") --upgrade pip \
&& pip3 install $(pip3 help install | grep -o "\-\-break-system-packages") meson cmake mako jinja2
&& pip3 install $(pip3 help install | grep -o "\-\-break-system-packages") meson cmake mako jinja2

# Avoids timeouts when using git and disable the detachedHead advice
RUN git config --global http.postbuffer 524288000 \
&& git config --global advice.detachedHead false
&& git config --global advice.detachedHead false

# Link to docker-build script
RUN ln -sf ${SOURCE_DIR}/docker-build.sh /docker-build.sh
Expand Down
37 changes: 23 additions & 14 deletions Dockerfile.win64.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,33 @@ ENV DEBIAN_FRONTEND=noninteractive \
DLLTOOL="x86_64-w64-mingw32-dlltool"

# Prepare Debian and mingw-w64 build environment
RUN \
apt-get -y update && \
apt-get -y install build-essential yasm nasm xxd pkgconf git curl wget unzip subversion autoconf automake libtool libtool-bin autopoint cmake clang texinfo texi2html help2man flex bison gperf gettext itstool ragel libc6-dev libssl-dev gtk-doc-tools gobject-introspection gawk meson ninja-build p7zip-full python3-distutils python3-apt python-is-python3 zip quilt binutils-mingw-w64-x86-64 gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 gfortran-mingw-w64-x86-64 && \
rm /usr/lib/gcc/*-w64-mingw32/*/libstdc++*.dll* && \
rm /usr/lib/gcc/*-w64-mingw32/*/libgcc_s* && \
rm /usr/lib/gcc/*-w64-mingw32/*/*.dll.a && \
rm /usr/*-w64-mingw32/lib/*.dll.a
RUN apt-get -y update \
&& apt-get install --no-install-recommends -y \
build-essential yasm nasm xxd pkgconf git curl \
wget unzip subversion autoconf automake libtool \
libtool-bin autopoint cmake clang texinfo texi2html \
help2man flex bison gperf gettext itstool ragel \
libc6-dev libssl-dev gtk-doc-tools gobject-introspection \
gawk meson ninja-build p7zip-full python3-distutils \
python3-apt python-is-python3 zip quilt \
binutils-mingw-w64-x86-64 gcc-mingw-w64-x86-64 \
g++-mingw-w64-x86-64 gfortran-mingw-w64-x86-64 \
&& apt-get clean autoclean -y \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /usr/lib/gcc/*-w64-mingw32/*/libstdc++*.dll* \
&& rm -rf /usr/lib/gcc/*-w64-mingw32/*/libgcc_s* \
&& rm -rf /usr/lib/gcc/*-w64-mingw32/*/*.dll.a \
&& rm -rf /usr/*-w64-mingw32/lib/*.dll.a

# Avoids timeouts when using git and disable the detachedHead advice
RUN \
git config --global http.postbuffer 524288000 && \
git config --global advice.detachedHead false
RUN git config --global http.postbuffer 524288000 \
&& git config --global advice.detachedHead false

# Prepare build script and patches
RUN \
mkdir -p /opt/ffmpeg /opt/ffdeps ${SOURCE_DIR} && \
ln -sf ${SOURCE_DIR}/debian/patches ${SOURCE_DIR} && \
ln -sf ${SOURCE_DIR}/docker-build-win64.sh /docker-build-win64.sh
RUN mkdir -p /opt/ffmpeg /opt/ffdeps ${SOURCE_DIR} \
&& ln -sf ${SOURCE_DIR}/debian/patches ${SOURCE_DIR} \
&& ln -sf ${SOURCE_DIR}/docker-build-win64.sh /docker-build-win64.sh

VOLUME ${ARTIFACT_DIR}/

Expand Down

0 comments on commit 3132b1e

Please sign in to comment.