Skip to content

Commit

Permalink
Dockerfile 22.04 fixes
Browse files Browse the repository at this point in the history
Dockerfile 22.04 fixes

Signed-off-by: Milosz Linkiewicz <milosz.linkiewicz@intel.com>
  • Loading branch information
Mionsz committed Sep 13, 2024
1 parent 71892bb commit 3730f24
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 80 deletions.
187 changes: 110 additions & 77 deletions docker/Dockerfile.ubuntu22.04
Original file line number Diff line number Diff line change
@@ -1,87 +1,120 @@
# syntax=docker/dockerfile:1

# Copyright (c) 2020-2021 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause

# use Ubuntu 22.04 with Intel IPP
FROM intel/oneapi-basekit:2023.2-devel-ubuntu22.04 as build
# use Ubuntu 22.04 with Intel IPP
ARG IMAGE_CACHE_REGISTRY=docker.io
ARG IMAGE_NAME=intel/oneapi-basekit:2023.2-devel-ubuntu22.04

FROM ${IMAGE_CACHE_REGISTRY}/${IMAGE_NAME} AS build

RUN mkdir /opt/build
ARG PREFIX=/opt/build
ARG LD_LIBRARY_PATH="/opt/build/lib:/opt/build/lib64"
ARG DL_PREFIX=/opt

RUN rm /bin/sh && ln -s /bin/bash /bin/sh
ARG LD_LIBRARY_PATH="/opt/build/lib:/opt/build/lib64:${LD_LIBRARY_PATH}"
ENV DEBIAN_FRONTEND="noninteractive"
ENV TZ="Europe/Warsaw"
ARG FFMPEG_COMMIT_ID="n6.0"

# Update apt and install dependances
WORKDIR ${DL_PREFIX}/ffmpeg
SHELL ["/bin/bash", "-ex", "-o", "pipefail", "-c"]
RUN rm /etc/apt/sources.list.d/oneAPI.list && \
apt-get update && apt-get install -y \
libx265-dev \
libx264-dev \
zlib1g-dev \
nasm \
cmake

COPY . ${PREFIX}/Video-Super-Resolution-Library
RUN cd ${PREFIX}/Video-Super-Resolution-Library && \
./build.sh

WORKDIR /opt/build
RUN git config --global user.email "you@example.com"
RUN git clone https://github.com/FFmpeg/FFmpeg ffmpeg
WORKDIR /opt/build/ffmpeg
RUN git checkout -b n6.0 n6.0 && \
cp /opt/build/Video-Super-Resolution-Library/ffmpeg/*.patch . && \
cp /opt/build/Video-Super-Resolution-Library/ffmpeg/vf_raisr*.c ./libavfilter && \
git am *.patch

# Configure and build ffmpeg
apt-get update --fix-missing && \
apt-get full-upgrade -y && \
apt-get install --no-install-recommends -y \
libx265-dev \
libx264-dev \
zlib1g-dev \
nasm \
cmake && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
curl -Lf https://github.com/ffmpeg/ffmpeg/archive/${FFMPEG_COMMIT_ID}.tar.gz | \
tar -zx --strip-components=1 -C "${DL_PREFIX}/ffmpeg"

COPY . ${DL_PREFIX}/Video-Super-Resolution-Library

WORKDIR ${DL_PREFIX}/Video-Super-Resolution-Library
RUN git -C "${DL_PREFIX}/ffmpeg" apply "${DL_PREFIX}/Video-Super-Resolution-Library/ffmpeg/"*.patch && \
cp "${DL_PREFIX}/Video-Super-Resolution-Library/ffmpeg/vf_raisr"*.c "${DL_PREFIX}/ffmpeg/libavfilter" && \
./build.sh

# Configure and build ffmpeg
WORKDIR ${DL_PREFIX}/ffmpeg
RUN ./configure \
--enable-libipp \
--extra-cflags=-fopenmp \
--extra-ldflags=-fopenmp \
--enable-gpl \
--enable-libx264 \
--enable-libx265 \
--extra-libs='-lraisr -lstdc++ -lippcore -lippvm -lipps -lippi -lm -lintlc -lsvml' \
--enable-cross-compile \
--prefix="${PREFIX}" && \
make clean && make -j $(nproc) && \
make install

# cleanup
WORKDIR /opt/build
RUN \
ldd ${PREFIX}/bin/ffmpeg | cut -d ' ' -f 3 | xargs -i cp {} /usr/local/lib/ && \
cp /opt/intel/oneapi/ipp/latest/lib/intel64/libippik0.so.10.8 /usr/local/lib && \
cp /opt/intel/oneapi/ipp/latest/lib/intel64/libippsk0.so.10.8 /usr/local/lib && \
cp /opt/intel/oneapi/ipp/latest/lib/intel64/libippsn0.so.10.8 /usr/local/lib && \
cp /opt/intel/oneapi/ipp/latest/lib/intel64/libippsl9.so.10.8 /usr/local/lib && \
cp /opt/intel/oneapi/ipp/latest/lib/intel64/libippse9.so.10.8 /usr/local/lib && \
cp /opt/intel/oneapi/ipp/latest/lib/intel64/libippsy8.so.10.8 /usr/local/lib && \
cp /opt/intel/oneapi/ipp/latest/lib/intel64/libippsn8.so.10.8 /usr/local/lib && \
cp /opt/intel/oneapi/ipp/latest/lib/intel64/libippsm7.so.10.8 /usr/local/lib && \
cp -r ${PREFIX}/bin/* /usr/local/bin/ && \
cp -r ${PREFIX}/share/ffmpeg /usr/local/share/ && \
LD_LIBRARY_PATH=/usr/local/lib ffmpeg -buildconf && \
cp -r ${PREFIX}/include/libav* ${PREFIX}/include/libpostproc ${PREFIX}/include/libsw* /usr/local/include && \
mkdir -p /usr/local/lib/pkgconfig && \
for pc in ${PREFIX}/lib/pkgconfig/libav*.pc ${PREFIX}/lib/pkgconfig/libpostproc.pc ${PREFIX}/lib/pkgconfig/libsw*.pc; do \
sed "s:${PREFIX}:/usr/local:g" <"$pc" >/usr/local/lib/pkgconfig/"${pc##*/}"; \
done

# Copy the raisr filters from the raisr library
RUN mkdir /raisrfolder
RUN cp -r /opt/build/Video-Super-Resolution-Library/filters* /raisrfolder

FROM ubuntu:22.04 AS base

ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64

RUN mkdir /raisrfolder
COPY --from=build /usr/local /usr/local/
COPY --from=build /raisrfolder /raisrfolder

RUN ln -s /usr/local/bin/ffmpeg /raisrfolder/ffmpeg

WORKDIR /raisrfolder
# Run ffmpeg and verify that the raisr filter is supported
RUN ffmpeg -h filter=raisr
--enable-libipp \
--extra-cflags=-fopenmp \
--extra-ldflags=-fopenmp \
--enable-gpl \
--enable-libx264 \
--enable-libx265 \
--extra-libs='-lraisr -lstdc++ -lippcore -lippvm -lipps -lippi -lm -lintlc -lsvml' \
--enable-cross-compile \
--prefix="${PREFIX}" && \
make clean && make -j $(nproc) && \
make install

ENV LIBIPP="/opt/intel/oneapi/ipp/latest/lib/intel64"
WORKDIR ${PREFIX}/usr/local/lib
RUN ldd ${PREFIX}/bin/ffmpeg | cut -d ' ' -f 3 | xargs -i cp {} . && \
cp ${LIBIPP}/libippsk0.so.10.8 . && \
cp ${LIBIPP}/libippsn0.so.10.8 . && \
cp ${LIBIPP}/libippsl9.so.10.8 . && \
cp ${LIBIPP}/libippse9.so.10.8 . && \
cp ${LIBIPP}/libippsy8.so.10.8 . && \
cp ${LIBIPP}/libippsn8.so.10.8 . && \
cp ${LIBIPP}/libippsm7.so.10.8 . && \
cp ${LIBIPP}/libippik0.so.10.8 . && \
mv ${PREFIX}/bin ${PREFIX}/usr/local/ && \
LD_LIBRARY_PATH=${PREFIX}/usr/local/lib ${PREFIX}/usr/local/bin/ffmpeg -buildconf && \
rm -rf ${PREFIX}/include/ ${PREFIX}/share/ ${PREFIX}/lib/


ARG IMAGE_CACHE_REGISTRY
ARG IMAGE_NAME=library/ubuntu:22.04@sha256:adbb90115a21969d2fe6fa7f9af4253e16d45f8d4c1e930182610c4731962658

FROM ${IMAGE_CACHE_REGISTRY}/${IMAGE_NAME} AS base

LABEL org.opencontainers.image.authors="milosz.linkiewicz@intel.com,xiaoxia.liang@intel.com"
LABEL org.opencontainers.image.url="https://github.com/OpenVisualCloud/Video-Super-Resolution-Library"
LABEL org.opencontainers.image.title="Intel® Library for Video Super Resolution"
LABEL org.opencontainers.image.description="Intel® Library for Video Super Resolution. RAISR (Rapid and Accurate Image Super Resolution) algorithm implementation by Intel® Corporation, as FFmpeg plugin. Ubuntu 22.04 Docker image."
LABEL org.opencontainers.image.documentation="https://github.com/OpenVisualCloud/Video-Super-Resolution-Library/blob/master/README.md"
LABEL org.opencontainers.image.version="1.0.0"
LABEL org.opencontainers.image.vendor="Intel® Corporation"
LABEL org.opencontainers.image.licenses="BSD 3-Clause License"

ARG PREFIX=/opt/build
ENV TZ=Europe/Warsaw
ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64

SHELL ["/bin/bash", "-ex", "-o", "pipefail", "-c"]
WORKDIR /opt/raisrfolder
RUN apt-get update --fix-missing && \
apt-get full-upgrade -y && \
apt-get install --no-install-recommends -y \
sudo \
ca-certificates \
libx264-1* \
libx265-1* && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
groupadd -g 2110 vfio && \
useradd -m -s /bin/bash -G vfio -u 1002 raisr && \
usermod -aG sudo raisr

COPY --chown=raisr:raisr filters_1.5x /opt/raisrfolder/filters_1.5x
COPY --chown=raisr:raisr filters_2x /opt/raisrfolder/filters_2x
COPY --chown=raisr:raisr --from=build ${PREFIX} /

RUN ldconfig && \
ln -s /usr/local/bin/ffmpeg /opt/raisrfolder/ffmpeg && \
/opt/raisrfolder/ffmpeg -h filter=raisr

USER "raisr"
HEALTHCHECK --interval=30s --timeout=5s CMD ps aux | grep "ffmpeg" || exit 1

SHELL ["/bin/bash", "-c"]
CMD ["-h", "filter=raisr"]
ENTRYPOINT [ "/opt/raisrfolder/ffmpeg" ]
13 changes: 10 additions & 3 deletions docker_build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# This script is used to build the docker image of Intel Video Super Resolution.

Expand All @@ -14,9 +14,10 @@ if [ -n "$1" ]; then
centos) OS="centos" VERSION="7.9" ;;
*) echo "This version of dockerfile does not exist will build defualt image with ubuntu22.04."
esac
shift
fi

if [ -n "$2" ]; then
if [ -n "$1" ]; then
if [ $OS = "ubuntu" ]; then
case "$2" in
18.04) VERSION="18.04" ;;
Expand All @@ -30,7 +31,13 @@ if [ -n "$2" ]; then
*) echo "This version of dockerfile does not exist will build defualt image with centos7.9."
esac
fi
shift
fi

docker build -f ./docker/Dockerfile.${OS}${VERSION} --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} -t raisr:${OS}${VERSION} .
docker buildx build "$@" \
-f ./docker/Dockerfile.${OS}${VERSION} \
--build-arg http_proxy=${http_proxy} \
--build-arg https_proxy=${https_proxy} \
-t raisr:${OS}${VERSION} \
.

0 comments on commit 3730f24

Please sign in to comment.