forked from intel/media-delivery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
323 lines (280 loc) · 10.1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# Copyright (c) 2020 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# This file is automatically generated from .m4 template.
# To update, modify the template and regenerate.
ARG IMAGE=ubuntu:20.04
FROM $IMAGE AS content
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates wget && \
rm -rf /var/lib/apt/lists/*
# Refer to usage.txt for the content copyright notice(s)
RUN mkdir -p /downloads && cd /downloads && \
wget --progress=bar:force https://repositories.intel.com/media/usage.txt && \
wget --progress=bar:force https://repositories.intel.com/media/WAR_TRAILER_HiQ_10_withAudio.mp4
FROM ubuntu:20.04 as build
RUN mkdir -p /opt/build && mkdir -p /opt/dist
ENV PKG_CONFIG_PATH=/opt/intel/samples/lib/pkgconfig
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
g++ \
git \
make \
meson \
nasm \
patch \
pkg-config \
cython3 \
python3 \
python3-dev \
python3-numpy \
python3-setuptools \
python3-wheel && \
rm -rf /var/lib/apt/lists/*
# As of now we need 2 things from VMAF: libvmaf library against which we will link
# ffmpeg and model *.pkl files to be able to calculate VMAF.
RUN git clone --depth 1 --branch v2.2.1 https://github.com/Netflix/vmaf.git /opt/build/vmaf
COPY patches/vmaf /opt/build/vmaf
RUN cd /opt/build/vmaf && { set -e; \
for patch_file in $(find -iname "*.patch" | sort -n); do \
echo "Applying: ${patch_file}"; \
patch -p1 < ${patch_file}; \
done; }
RUN cd /opt/build/vmaf/libvmaf \
&& meson build \
--buildtype=release \
--prefix=/opt/intel/samples \
--libdir=/opt/intel/samples/lib \
&& ninja -j $(nproc --all) -C build \
&& DESTDIR=/opt/dist ninja -C build install \
&& ninja -C build install
RUN cd /opt/build/vmaf/python \
&& python3 setup.py build \
&& python3 setup.py bdist_wheel --dist-dir=/opt/wheel
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
tar \
g++ \
wget \
pkg-config \
nasm \
meson && \
rm -rf /var/lib/apt/lists/*
# build dav1d
ARG DAV1D_REPO=https://code.videolan.org/videolan/dav1d/-/archive/0.9.2/dav1d-0.9.2.tar.gz
RUN cd /opt/build && \
wget -O - ${DAV1D_REPO} | tar xz
RUN cd /opt/build/dav1d-0.9.2 && \
meson build --prefix=/opt/intel/samples --libdir /opt/intel/samples/lib --buildtype=plain && \
cd build && \
ninja install && \
DESTDIR=/opt/dist ninja install
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
g++ \
git \
libmfx-dev \
libva-dev \
libx264-dev \
libx265-dev \
make \
patch \
pkg-config \
yasm && \
rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/ffmpeg/ffmpeg /opt/build/ffmpeg && \
cd /opt/build/ffmpeg && \
git checkout f6a36c7
RUN cd /opt/build/ffmpeg && \
./configure \
--prefix=/opt/intel/samples \
--libdir=/opt/intel/samples/lib \
--disable-static \
--disable-doc \
--enable-shared \
--enable-vaapi \
--enable-libmfx \
--enable-gpl \
--enable-libx264 \
--enable-libx265 \
--enable-version3 \
--enable-libvmaf \
--enable-libdav1d \
&& make -j $(nproc --all) \
&& make install DESTDIR=/opt/dist \
&& make install
# Cleaning up...
RUN rm -rf /opt/build/ffmpeg
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
asciidoc-base \
docbook-utils \
docbook-xsl \
make \
xmlto \
xsltproc && \
rm -rf /var/lib/apt/lists/*
# Building some manual pages for the sample
COPY doc/man /opt/build/manuals
RUN cd /opt/build/manuals && make -j $(nproc --all) && \
DESTDIR=/opt/dist make prefix=/opt/intel/samples install
RUN rm -rf /opt/build/manuals
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
bison \
flex \
git \
libcairo-dev \
libdrm-dev \
libdw-dev \
libkmod-dev \
libpciaccess-dev \
libpixman-1-dev \
libprocps-dev \
libudev-dev \
meson \
pkg-config && \
rm -rf /var/lib/apt/lists/*
ARG IGT_REPO=https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
RUN git clone $IGT_REPO /opt/build/igt
RUN cd /opt/build/igt \
&& git checkout 1869d560c550ac273f495076ead46f8a337fc20b \
&& meson build \
--buildtype=release \
--prefix=/opt/intel/samples \
--libdir=/opt/intel/samples/lib \
-Ddocs=disabled -Dman=disabled -Dlibdrm_drivers=intel \
-Doverlay=disabled -Drunner=disabled -Dtests=disabled \
&& ninja -j $(nproc --all) -C build \
&& DESTDIR=/opt/dist ninja -C build install \
&& ninja -C build install
# Ok, here goes the final image end-user will actually see
FROM ubuntu:20.04
LABEL vendor="Intel Corporation"
COPY --from=content /downloads /opt/data/embedded
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3 \
python3-pip \
intel-media-va-driver-non-free \
libigfxcmrt7 \
libmfx1 \
libva-drm2 \
libx264-155 \
libx265-179 \
libxcb-shm0 \
less \
man-db \
libglib2.0-0 \
libnginx-mod-http-lua \
libnginx-mod-rtmp \
linux-tools-generic \
nginx \
pciutils \
python3-matplotlib \
python3-numpy \
socat \
tmux \
vainfo \
curl \
sudo \
vim \
wget \
&& \
rm -rf /var/lib/apt/lists/*
COPY --from=build /opt/dist /
RUN echo "/opt/intel/samples/lib" >> /etc/ld.so.conf.d/all-libs.conf && ldconfig
# Custom component installation rules, if any...
COPY --from=build /opt/wheel /opt/wheel
RUN python3 -m pip install --no-deps --prefix=/opt/intel/samples /opt/wheel/* && rm -rf /opt/wheel
# Restoring man which is excluded from the minimal ubuntu image
RUN rm -f /usr/bin/man && dpkg-divert --quiet --remove --rename /usr/bin/man
RUN setcap cap_sys_admin+ep $(find /opt -name intel_gpu_top)
# perf is tight to particular kernel version per old WA which will never
# be fixed, we just need to use some version
RUN ln -fs $(find /usr/lib/linux-tools -name perf) /usr/bin/perf;
# Granting CAP_SYS_ADMIN to the Linux perf to be able to get global perf
# events (specifically: i915 events). Mind that this will work if container
# is started with:
# --cap-add SYS_ADMIN --security-opt="no-new-privileges:false"
# If it was started with
# --cap-add SYS_ADMIN --security-opt="no-new-privileges:true"
# then you need to adjust /proc/sys/kernel/perf_event_paranoid on a host to have
# value <=0
RUN setcap cap_sys_admin+ep $(readlink -f $(which perf))
#RUN setcap cap_sys_admin+ep $(readlink -f $(which intel_gpu_top))
# Installing entrypoint helper scripts
COPY assets/demo-alive /usr/bin/
COPY assets/demo-bash /usr/bin/
COPY assets/hello-bash /usr/bin/
# Create default container user <user>
RUN groupadd -r user && useradd -lrm -s /bin/bash -g user user
RUN usermod -aG sudo user && \
sed -i -e "s/%sudo.*/%sudo ALL=(ALL) NOPASSWD:ALL/g" /etc/sudoers
# Creating locations sample will need and giving permissions
# to the default user
RUN mkdir -p /opt/data/content
RUN mkdir -p /opt/data/artifacts && chown user /opt/data/artifacts
RUN mkdir -p /opt/data/duplicates && chown user /opt/data/duplicates
# The following are locations used by nginx to produce HLS streams,
# dump logs, etc.
RUN mkdir -p /var/www/hls && chown user /var/www/hls
RUN chown -R user /var/log/nginx
RUN chown -R user /var/lib/nginx
# Setting up sample
ARG SAMPLE=cdn
COPY . /tmp/src
RUN cd /tmp/src/samples/$SAMPLE && ./setup.sh /opt/intel/samples && rm -rf /tmp/src
# Setting up environment common for all samples
# Declaring volumes which you might wish to optionally mount
# * /opt/data/content is where you can put your own content to access from inside
# the sample demos
# * /opt/data/artifacts is a location where sample will produce some output
# artifacts like generated or captured stream and logs. You can wish to twick
# this location to get artifacts on your host system
# * /var/www/hls is a location where sample demos will generate HLS streams. You
# might wish to twick this location to get access to these streams. Mind that
# this is server side raw HLS stream. If you run some demo client to capture
# streaming video - look in the /opt/data/artifacts
VOLUME /opt/data/content
VOLUME /opt/data/artifacts
VOLUME /var/www/hls
# Check running container healthy status with:
# docker inspect --format="{{json .State.Health}}" <container-id>
HEALTHCHECK CMD /usr/bin/demo-alive
# hello-bash is a default command which will be executed by demo-bash if
# user did not provide any arguments starting the container. Basically hello-bash
# will print welcome message and enter regular bash with correct environment.
CMD ["/usr/bin/hello-bash"]
# demo-bash will execute whatever command is provided by the user making
# sure that environment settings are correct.
ENTRYPOINT ["/usr/bin/demo-bash"]
# ... end of custom installation rules
# Custom component environment variables, if any...
# ... end of custom environment variables
USER user
WORKDIR /home/user