forked from AirenSoft/OvenMediaEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.nv
303 lines (263 loc) · 11.7 KB
/
Dockerfile.nv
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
FROM ubuntu:18.04 AS base
## Install libraries by package
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y tzdata
FROM base AS build
WORKDIR /tmp
ARG PREFIX=/opt/ovenmediaengine
ARG MAKEFLAGS="-j16"
ENV OME_VERSION=master \
OPENSSL_VERSION=1.1.1i \
SRTP_VERSION=2.2.0 \
SRT_VERSION=1.4.2 \
OPUS_VERSION=1.1.3 \
X264_VERSION=20190513-2245-stable \
X265_VERSION=3.4 \
VPX_VERSION=1.7.0 \
FDKAAC_VERSION=0.1.5 \
FFMPEG_VERSION=4.3.2 \
JEMALLOC_VERSION=5.2.1 \
PCRE2_VERSION=10.35
## Install build utils
RUN apt-get -y install build-essential nasm autoconf libtool zlib1g-dev tclsh cmake curl pkg-config bc apt-utils
##################################################################################################################################
## Install Nvidia GPU(NVENC, NVDEC) build envrionment
RUN \
apt-get install -y --no-install-recommends \
gnupg2 curl ca-certificates && \
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub | apt-key add - && \
echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list && \
echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list && \
rm -rf /var/lib/apt/lists/*
ENV CUDA_VERSION 11.3.0
# For libraries in the cuda-compat-* package: https://docs.nvidia.com/cuda/eula/index.html#attachment-a
RUN \
apt-get update && apt-get install -y --no-install-recommends \
cuda-cudart-11-3=11.3.58-1 \
cuda-compat-11-3 \
&& ln -s cuda-11.3 /usr/local/cuda && \
rm -rf /var/lib/apt/lists/*
# Required for nvidia-docker v1
RUN \
echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf \
&& echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64
# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV NVIDIA_REQUIRE_CUDA="cuda>=11.3 brand=tesla,driver>=418,driver<419 brand=tesla,driver>=440,driver<441 driver>=450"
ENV NCCL_VERSION 2.9.6
RUN \
apt-get update && apt-get install -y --no-install-recommends \
cuda-libraries-11-3=11.3.0-1 \
libnpp-11-3=11.3.3.44-1 \
cuda-nvtx-11-3=11.3.58-1 \
libcublas-11-3=11.4.2.10064-1 \
libcusparse-11-3=11.5.0.58-1 \
libnccl2=$NCCL_VERSION-1+cuda11.3 \
&& rm -rf /var/lib/apt/lists/*
# apt from auto upgrading the cublas package. See https://gitlab.com/nvidia/container-images/cuda/-/issues/88
RUN \
apt-mark hold libcublas-11-3 libnccl2
RUN \
apt-get update && apt-get install -y --no-install-recommends \
cuda-cudart-dev-11-3=11.3.58-1 \
cuda-command-line-tools-11-3=11.3.0-1 \
cuda-minimal-build-11-3=11.3.0-1 \
cuda-libraries-dev-11-3=11.3.0-1 \
cuda-nvml-dev-11-3=11.3.58-1 \
libnpp-dev-11-3=11.3.3.44-1 \
libnccl-dev=2.9.6-1+cuda11.3 \
libcublas-dev-11-3=11.4.2.10064-1 \
libcusparse-dev-11-3=11.5.0.58-1 \
&& rm -rf /var/lib/apt/lists/*
# apt from auto upgrading the cublas package. See https://gitlab.com/nvidia/container-images/cuda/-/issues/88
RUN apt-mark hold libcublas-dev-11-3 libnccl-dev
ENV LIBRARY_PATH /usr/local/cuda/lib64/stubs
ENV NVCC_HEADERS=11.0.10.1
# Build NvCodecHeaders
RUN \
DIR=/tmp/nvcc-hdr && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://github.com/FFmpeg/nv-codec-headers/releases/download/n${NVCC_HEADERS}/nv-codec-headers-${NVCC_HEADERS}.tar.gz | tar -xz --strip-components=1 && \
make install && \
rm -rf ${DIR}
##
###################################################################################################################################
## Build OpenSSL
RUN \
OPENSSL_DOWNLOAD_NAME=$(echo "${OPENSSL_VERSION}" | sed 's/\./_/g') && \
DIR=/tmp/openssl && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_DOWNLOAD_NAME}.tar.gz | tar -xz --strip-components=1 && \
./config --prefix="${PREFIX}" --openssldir="${PREFIX}" -Wl,-rpath="${PREFIX}/lib" shared no-idea no-mdc2 no-rc5 no-ec2m no-ecdh no-ecdsa no-async && \
make && \
make install_sw && \
rm -rf ${DIR} && \
rm -rf ${PREFIX}/bin
## Build SRTP
RUN \
DIR=/tmp/srtp && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://github.com/cisco/libsrtp/archive/v${SRTP_VERSION}.tar.gz | tar -xz --strip-components=1 && \
./configure --prefix="${PREFIX}" --enable-shared --disable-static --enable-openssl --with-openssl-dir="${PREFIX}" && \
make shared_library && \
make install && \
rm -rf ${DIR}
## Build SRT
RUN \
DIR=/tmp/srt && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://github.com/Haivision/srt/archive/v${SRT_VERSION}.tar.gz | tar -xz --strip-components=1 && \
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}" ./configure \
--prefix="${PREFIX}" --enable-shared --disable-static && \
make && \
make install && \
rm -rf ${DIR} && \
rm -rf ${PREFIX}/bin
## Build OPUS
RUN \
DIR=/tmp/opus && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://archive.mozilla.org/pub/opus/opus-${OPUS_VERSION}.tar.gz | tar -xz --strip-components=1 && \
autoreconf -fiv && \
./configure --prefix="${PREFIX}" --enable-shared --disable-static && \
make && \
make install && \
rm -rf ${PREFIX}/share && \
rm -rf ${DIR}
## Build X264
RUN \
DIR=/tmp/x264 && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-${X264_VERSION}.tar.bz2 | tar -jx --strip-components=1 && \
./configure --prefix="${PREFIX}" --enable-shared --enable-pic --disable-cli && \
make && \
make install && \
rm -rf ${DIR}
## Build X265
RUN \
DIR=/tmp/x265 && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://github.com/videolan/x265/archive/${X265_VERSION}.tar.gz | tar -zx --strip-components=1 && \
cd ${DIR}/build/linux && \
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DENABLE_SHARED:bool=on ../../source && \
make && \
make install && \
rm -rf ${DIR}
## Build VPX
RUN \
DIR=/tmp/vpx && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://codeload.github.com/webmproject/libvpx/tar.gz/v${VPX_VERSION} | tar -xz --strip-components=1 && \
./configure --prefix="${PREFIX}" --enable-vp8 --enable-pic --enable-shared --disable-static --disable-vp9 --disable-debug --disable-examples --disable-docs --disable-install-bins && \
make && \
make install && \
rm -rf ${DIR}
## Build FDK-AAC
RUN \
DIR=/tmp/aac && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://github.com/mstorsjo/fdk-aac/archive/v${FDKAAC_VERSION}.tar.gz | tar -xz --strip-components=1 && \
autoreconf -fiv && \
./configure --prefix="${PREFIX}" --enable-shared --disable-static --datadir=/tmp/aac && \
make && \
make install && \
rm -rf ${DIR}
## Build FFMPEG
RUN \
DIR=/tmp/ffmpeg && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n${FFMPEG_VERSION}.tar.gz | tar -xz --strip-components=1 && \
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH}" ./configure \
--prefix="${PREFIX}" \
--enable-gpl \
--enable-nonfree \
--extra-cflags="-I${PREFIX}/include -I/usr/local/cuda/include" \
--extra-ldflags="-L${PREFIX}/lib -L/usr/local/cuda/lib64 -Wl,-rpath,${PREFIX}/lib" \
--extra-libs=-ldl \
--enable-shared \
--disable-static \
--disable-debug \
--disable-doc \
--disable-programs \
--disable-avdevice --disable-dct --disable-dwt --disable-lsp --disable-lzo --disable-rdft --disable-faan --disable-pixelutils \
--enable-zlib --enable-libopus --enable-libvpx --enable-libfdk_aac --enable-libx264 --enable-libx265 --enable-libnpp \
--disable-everything \
--enable-hwaccel=h264_nvdec,hevc_nvdec \
--enable-encoder=libvpx_vp8,libvpx_vp9,libopus,libfdk_aac,libx264,libx265,mjpeg,png,h264_nvenc,hevc_nvenc \
--enable-decoder=aac,aac_latm,aac_fixed,h264,hevc,opus,vp8,h264_nvdec,hevc_nvdec \
--enable-parser=aac,aac_latm,aac_fixed,h264,hevc,opus,vp8 \
--enable-network --enable-protocol=tcp --enable-protocol=udp --enable-protocol=rtp,file,rtmp --enable-demuxer=rtsp --enable-muxer=mp4,webm,mpegts,flv,mpjpeg \
--enable-filter=asetnsamples,aresample,aformat,channelmap,channelsplit,scale,transpose,fps,settb,asettb,format && \
make && \
make install && \
rm -rf ${PREFIX}/share && \
rm -rf ${DIR}
## Build jemalloc
RUN \
DIR=/tmp/jemalloc && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://github.com/jemalloc/jemalloc/releases/download/${JEMALLOC_VERSION}/jemalloc-${JEMALLOC_VERSION}.tar.bz2 | tar -jx --strip-components=1 && \
./configure --prefix="${PREFIX}" && \
make && \
make install_include install_lib && \
rm -rf ${DIR}
## Build pcre2
RUN \
DIR=/tmp/libpcre2 && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf https://ftp.pcre.org/pub/pcre/pcre2-${PCRE2_VERSION}.tar.gz | tar -xz --strip-components=1 && \
./configure --prefix="${PREFIX}" \
--disable-static \
--enable-jit=auto && \
make && \
make install && \
rm -rf ${DIR} && \
rm -rf ${PREFIX}/bin
## Build OvenMediaEngine
RUN \
DIR=/tmp/ome && \
mkdir -p ${DIR} && \
cd ${DIR} && \
curl -sLf http://dev.airensoft.com/~pub/test/master.tar.gz | tar -xz --strip-components=1 && \
cd src && \
make
## Make running environment
RUN \
DIR=/tmp/ome && \
cd ${DIR} && \
cd src && \
mkdir -p ${PREFIX}/bin/origin_conf && \
mkdir -p ${PREFIX}/bin/edge_conf && \
strip ./bin/DEBUG/OvenMediaEngine && \
cp ./bin/DEBUG/OvenMediaEngine ${PREFIX}/bin/ && \
cp ../misc/conf_examples/Origin.xml ${PREFIX}/bin/origin_conf/Server.xml && \
cp ../misc/conf_examples/Logger.xml ${PREFIX}/bin/origin_conf/Logger.xml && \
cp ../misc/conf_examples/Edge.xml ${PREFIX}/bin/edge_conf/Server.xml && \
cp ../misc/conf_examples/Logger.xml ${PREFIX}/bin/edge_conf/Logger.xml && \
rm -rf ${DIR}
FROM base AS release
MAINTAINER Jeheon Han <[email protected]>
# * NVIDIA GPU Environment Variables
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,video
ENV NVIDIA_REQUIRE_CUDA "cuda>=11.3 brand=tesla,driver>=418,driver<419 brand=tesla,driver>=440,driver<441 driver>=450"
WORKDIR /opt/ovenmediaengine/bin
EXPOSE 80/tcp 8080/tcp 8090/tcp 1935/tcp 3333/tcp 3334/tcp 4000-4005/udp 10000-10010/udp 9000/tcp
COPY --from=build /opt/ovenmediaengine /opt/ovenmediaengine
# Default run as Origin mode
CMD ["/opt/ovenmediaengine/bin/OvenMediaEngine", "-c", "origin_conf"]