diff --git a/Dockerfile b/Dockerfile index c7576d6..8d6522d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ # Template from templates/templates/00-FROM.in # # Pull from the internal cache of images -FROM amr-registry.caas.intel.com/vtt-osgc/os/ubuntu:disco +FROM amr-registry.caas.intel.com/vtt-osgc/os/ubuntu:disco AS base # @@ -36,11 +36,13 @@ RUN echo "Acquire::http::proxy \"http://proxy-chain.intel.com:911/\";\n" \ # # Install Intel CA5A cert so Intel certs are recognized -RUN apt-get update \ +RUN apt-get -q update \ && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ ca-certificates \ wget \ unzip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} \ && mkdir -p /usr/local/share/ca-certificates \ && wget -qO tmp.zip http://certificates.intel.com/repository/certificates/IntelSHA2RootChain-Base64.zip \ && unzip tmp.zip -d /usr/local/share/ca-certificates \ @@ -48,6 +50,7 @@ RUN apt-get update \ && wget -qO tmp.zip http://certificates.intel.com/repository/certificates/Intel%20Root%20Certificate%20Chain%20Base64.zip \ && unzip tmp.zip -d /usr/local/share/ca-certificates \ && rm tmp.zip \ + && apt-get remove -y wget unzip \ && update-ca-certificates --fresh @@ -60,26 +63,52 @@ RUN apt-get update \ # # NOTE: We use DEBIAN_FRONTEND=noninteractive to prevent krb5-user from # trying to prompt for configuration details during install. -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install \ - -y --no-install-recommends -q \ - net-tools \ - iputils-ping \ - sudo \ - wget \ - locales \ - software-properties-common +RUN apt-get -q update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends -q \ + locales \ + software-properties-common # Set up locales RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8 ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 # -# Template from templates/templates/20-create-agama-user.in +# Template from templates/templates/20-agama-packages.in +# +FROM base AS agama + +# Update and install gpg-agent as it isn't in the base Ubuntu image and is needed for apt-key +RUN apt-get -q update \ + && DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -q -y install \ + wget \ + gpg-agent \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} + +# Fetch and install the signing key for OSGC's Agama repository +RUN wget --no-proxy --quiet -O /tmp/aptly.key http://osgc.jf.intel.com/packages/agama/ubuntu/aptly_repo_signing.key \ + && APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn apt-key add /tmp/aptly.key \ + && rm /tmp/aptly.key + +# Add internal Agama repository +RUN apt-add-repository "deb [arch=amd64] http://osgc.jf.intel.com/packages/agama/ubuntu disco main" + +RUN apt-get remove -y wget + +# +# Template from templates/templates/25-agama-user.in # # Create user 'agama' and add them to 'sudo' for sudo access and set # the passwd to 'agama' -# + +FROM agama AS agama-user + +RUN apt-get -q update \ + && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ + sudo \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} + # NOTE: Requires 'sudo' package to already be installed RUN groupadd -r agama \ && useradd --no-log-init \ @@ -92,33 +121,6 @@ RUN groupadd -r agama \ # Set 'sudo' to NOPASSWD for all container users RUN sed -i -e 's,%sudo.*,%sudo ALL=(ALL) NOPASSWD:ALL,g' /etc/sudoers -# -# Template from templates/templates/25-install-agama.in -# -# Update and install gpg-agent as it isn't in the base Ubuntu image and is needed for apt-key -RUN apt-get -q update \ - && DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -q -y install \ - gpg-agent - -# Fetch and install the signing key for OSGC's Agama repository -RUN wget --no-proxy --quiet -O /tmp/aptly.key http://osgc.jf.intel.com/packages/agama/ubuntu/aptly_repo_signing.key \ - && APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn apt-key add /tmp/aptly.key \ - && rm /tmp/aptly.key - -# Add internal Agama repository -RUN apt-add-repository "deb [arch=amd64] http://osgc.jf.intel.com/packages/agama/ubuntu disco main" - -# Update and install the Mesa, OpenCL, and Media from Agama -RUN apt-get -q update \ - && DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -q -y install \ - libgl1-mesa-glx=19.1.0.agama-176 libgl1-mesa-dri=19.1.0.agama-176 \ - intel-opencl=19.38.176 \ - intel-media=2.10.176 libva2=2.6.0.agama-176 \ - ocl-icd-libopencl1 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - - # # Solution begins here (from Dockerfile.solution) # @@ -131,7 +133,7 @@ RUN apt-get -q update \ # image isn't polluted with build artifacts # # NOTE: This image will only work with Ubuntu 19.04 (disco) and newer - +FROM agama-user AS solution-build # Install git and build tools, clone ffmpeg, and get ready to build it RUN apt-get update \ @@ -158,16 +160,36 @@ ENV LIBVA_DRIVER_NAME=iHD WORKDIR /home/agama/ffmpeg RUN ./configure --arch=x86_64 --disable-yasm --enable-vaapi --enable-libmfx \ - && make \ + && make -j $(nproc --all) \ && make install -WORKDIR /home/agama +FROM agama-user + +ENV LIBVA_DRIVER_NAME=iHD + +# Update and install the Mesa, OpenCL, and Media from Agama +# +# NOTE: libva requires libpciaccess0, however it doesn't depend on it +# so explicitly install it. +RUN apt-get -q update \ + && DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -q -y install \ + intel-media=2.10.176 \ + intel-gmmlib=19.3.0.176 \ + libva2=2.6.0.agama-176 \ + libmfx1=19.2.pre3.agama-176 \ + vainfo=2.6.0.agama-176 \ + libpciaccess0 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* -# ffmpeg is installed; the build and source trees are no longer needed -# RUN rm -rf /home/agama/ffmpeg COPY assets/ /assets/ +# Copy ffmpeg and ffprobe from build container +COPY --from=solution-build /usr/local/bin/ /usr/local/bin/ + +WORKDIR /home/agama + ENTRYPOINT [ "/assets/entry" ] # @@ -178,11 +200,6 @@ ENTRYPOINT [ "/assets/entry" ] # changes,) causing all subsequent layers to be # regenerated. -# Clean up APT content that might still be around -#RUN apt-get clean autoclean \ -# && apt-get autoremove -y \ -# && rm -rf /var/lib/${apt,dpkg,cache,log} - # Ensure that each Docker container self-documents the # versions included in it diff --git a/Dockerfile.solution b/Dockerfile.solution index 67f2ff5..15e8983 100644 --- a/Dockerfile.solution +++ b/Dockerfile.solution @@ -7,7 +7,7 @@ # image isn't polluted with build artifacts # # NOTE: This image will only work with Ubuntu 19.04 (disco) and newer - +FROM agama-user AS solution-build # Install git and build tools, clone ffmpeg, and get ready to build it RUN apt-get update \ @@ -34,14 +34,34 @@ ENV LIBVA_DRIVER_NAME=iHD WORKDIR /home/agama/ffmpeg RUN ./configure --arch=x86_64 --disable-yasm --enable-vaapi --enable-libmfx \ - && make \ + && make -j $(nproc --all) \ && make install -WORKDIR /home/agama +FROM agama-user + +ENV LIBVA_DRIVER_NAME=iHD + +# Update and install the Mesa, OpenCL, and Media from Agama +# +# NOTE: libva requires libpciaccess0, however it doesn't depend on it +# so explicitly install it. +RUN apt-get -q update \ + && DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -q -y install \ + intel-media=$INTEL_MEDIA_VERSION \ + intel-gmmlib=$INTEL_GMMLIB_VERSION \ + libva2=$LIBVA2_VERSION \ + libmfx1=$LIBMFX1_VERSION \ + vainfo=$VAINFO_VERSION \ + libpciaccess0 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* -# ffmpeg is installed; the build and source trees are no longer needed -# RUN rm -rf /home/agama/ffmpeg COPY assets/ /assets/ +# Copy ffmpeg and ffprobe from build container +COPY --from=solution-build /usr/local/bin/ /usr/local/bin/ + +WORKDIR /home/agama + ENTRYPOINT [ "/assets/entry" ] diff --git a/templates/00-FROM.in b/templates/00-FROM.in index 1fd5763..c441ee0 100644 --- a/templates/00-FROM.in +++ b/templates/00-FROM.in @@ -1,3 +1,3 @@ # Pull from the internal cache of images -FROM amr-registry.caas.intel.com/vtt-osgc/os/$OS_DISTRO:$OS_RELEASE +FROM amr-registry.caas.intel.com/vtt-osgc/os/$OS_DISTRO:$OS_RELEASE AS base diff --git a/templates/08-intel-certs.in b/templates/08-intel-certs.in index edf6df8..a5770e8 100644 --- a/templates/08-intel-certs.in +++ b/templates/08-intel-certs.in @@ -1,10 +1,12 @@ # Install Intel CA5A cert so Intel certs are recognized -RUN apt-get update \ +RUN apt-get -q update \ && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ ca-certificates \ wget \ unzip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} \ && mkdir -p /usr/local/share/ca-certificates \ && wget -qO tmp.zip http://certificates.intel.com/repository/certificates/IntelSHA2RootChain-Base64.zip \ && unzip tmp.zip -d /usr/local/share/ca-certificates \ @@ -12,5 +14,6 @@ RUN apt-get update \ && wget -qO tmp.zip http://certificates.intel.com/repository/certificates/Intel%20Root%20Certificate%20Chain%20Base64.zip \ && unzip tmp.zip -d /usr/local/share/ca-certificates \ && rm tmp.zip \ + && apt-get remove -y wget unzip \ && update-ca-certificates --fresh diff --git a/templates/10-default-packages.in b/templates/10-default-packages.in index 9d0d290..2282054 100644 --- a/templates/10-default-packages.in +++ b/templates/10-default-packages.in @@ -4,15 +4,10 @@ # # NOTE: We use DEBIAN_FRONTEND=noninteractive to prevent krb5-user from # trying to prompt for configuration details during install. -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install \ - -y --no-install-recommends -q \ - net-tools \ - iputils-ping \ - sudo \ - wget \ - locales \ - software-properties-common +RUN apt-get -q update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends -q \ + locales \ + software-properties-common # Set up locales RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8 diff --git a/templates/20-create-agama-user.in b/templates/20-create-agama-user.in deleted file mode 100644 index bdd7911..0000000 --- a/templates/20-create-agama-user.in +++ /dev/null @@ -1,14 +0,0 @@ -# Create user 'agama' and add them to 'sudo' for sudo access and set -# the passwd to 'agama' -# -# NOTE: Requires 'sudo' package to already be installed -RUN groupadd -r agama \ -&& useradd --no-log-init \ - -s /bin/bash \ - -r -m \ - -g agama \ - -G sudo \ - -p $(echo "agama" | openssl passwd -stdin) agama - -# Set 'sudo' to NOPASSWD for all container users -RUN sed -i -e 's,%sudo.*,%sudo ALL=(ALL) NOPASSWD:ALL,g' /etc/sudoers diff --git a/templates/25-install-agama.in b/templates/25-install-agama.in deleted file mode 100644 index 9feb136..0000000 --- a/templates/25-install-agama.in +++ /dev/null @@ -1,23 +0,0 @@ -# Update and install gpg-agent as it isn't in the base Ubuntu image and is needed for apt-key -RUN apt-get -q update \ - && DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -q -y install \ - gpg-agent - -# Fetch and install the signing key for OSGC's Agama repository -RUN wget --no-proxy --quiet -O /tmp/aptly.key http://osgc.jf.intel.com/packages/agama/ubuntu/aptly_repo_signing.key \ - && APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn apt-key add /tmp/aptly.key \ - && rm /tmp/aptly.key - -# Add internal Agama repository -RUN apt-add-repository "deb [arch=amd64] http://osgc.jf.intel.com/packages/agama/ubuntu disco main" - -# Update and install the Mesa, OpenCL, and Media from Agama -RUN apt-get -q update \ - && DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -q -y install \ - libgl1-mesa-glx=$LIBGL1_MESA_GLX_VERSION libgl1-mesa-dri=$LIBGL1_MESA_DRI_VERSION \ - intel-opencl=$INTEL_OPENCL_VERSION \ - intel-media=$INTEL_MEDIA_VERSION libva2=$LIBVA2_VERSION \ - ocl-icd-libopencl1 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - diff --git a/templates/ending.in b/templates/ending.in index da40d70..79447e3 100644 --- a/templates/ending.in +++ b/templates/ending.in @@ -3,11 +3,6 @@ # changes,) causing all subsequent layers to be # regenerated. -# Clean up APT content that might still be around -#RUN apt-get clean autoclean \ -# && apt-get autoremove -y \ -# && rm -rf /var/lib/${apt,dpkg,cache,log} - # Ensure that each Docker container self-documents the # versions included in it