Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit c50ef9f

Browse files
authored
Modify Dockerfile and update README (#467)
1 parent 1c265a6 commit c50ef9f

File tree

4 files changed

+351
-23
lines changed

4 files changed

+351
-23
lines changed

docker/Dockerfile

Lines changed: 213 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,228 @@
33
#
44
# Base image Ubuntu 18.04
55

6-
FROM ubuntu:18.04
76

8-
ENV DEBIAN_FRONTEND=noninteractive
9-
ENV MEDIA_SDK_VER=18.4.0
7+
FROM ubuntu:18.04 AS owt-build
8+
WORKDIR /home
9+
10+
# COMMON BUILD TOOLS
11+
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y -q --no-install-recommends build-essential autoconf make git wget pciutils cpio libtool lsb-release ca-certificates pkg-config bison flex libcurl4-gnutls-dev zlib1g-dev nasm yasm m4 autoconf libtool automake cmake libfreetype6-dev
12+
13+
14+
# Build libnice
15+
ARG NICE_VER="0.1.4"
16+
ARG NICE_REPO=http://nice.freedesktop.org/releases/libnice-${NICE_VER}.tar.gz
17+
ARG LIBNICE_PATCH_VER="4.3"
18+
ARG LIBNICE_PATCH_REPO=https://github.com/open-webrtc-toolkit/owt-server/archive/v${LIBNICE_PATCH_VER}.tar.gz
19+
20+
RUN apt-get update && apt-get install -y -q --no-install-recommends libglib2.0-dev
21+
22+
RUN wget -O - ${NICE_REPO} | tar xz && \
23+
cd libnice-${NICE_VER} && \
24+
wget -O - ${LIBNICE_PATCH_REPO} | tar xz && \
25+
patch -p1 < owt-server-${LIBNICE_PATCH_VER}/scripts/patches/libnice014-agentlock.patch && \
26+
patch -p1 < owt-server-${LIBNICE_PATCH_VER}/scripts/patches/libnice014-agentlock-plus.patch && \
27+
patch -p1 < owt-server-${LIBNICE_PATCH_VER}/scripts/patches/libnice014-removecandidate.patch && \
28+
patch -p1 < owt-server-${LIBNICE_PATCH_VER}/scripts/patches/libnice014-keepalive.patch && \
29+
patch -p1 < owt-server-${LIBNICE_PATCH_VER}/scripts/patches/libnice014-startcheck.patch && \
30+
./configure --prefix="/usr/local" --libdir=/usr/local/lib/x86_64-linux-gnu && \
31+
make -s V=0 && \
32+
make install
33+
34+
35+
# Build open ssl
36+
ARG OPENSSL_BASE="1.0.2"
37+
ARG OPENSSL_VER="1.0.2t"
38+
ARG OPENSSL_REPO=http://www.openssl.org/source/old/${OPENSSL_BASE}/openssl-${OPENSSL_VER}.tar.gz
39+
40+
RUN wget -O - ${OPENSSL_REPO} | tar xz && \
41+
cd openssl-${OPENSSL_VER} && \
42+
./config no-ssl3 --prefix="/usr/local" -fPIC && \
43+
make depend && \
44+
make -s V=0 && \
45+
make install
46+
47+
48+
# Build libre
49+
ARG LIBRE_VER="v0.4.16"
50+
ARG LIBRE_REPO=https://github.com/creytiv/re.git
51+
52+
RUN git clone ${LIBRE_REPO} && \
53+
cd re && \
54+
git checkout ${LIBRE_VER} && \
55+
make SYSROOT_ALT="/usr" RELEASE=1 && \
56+
make install SYSROOT_ALT="/usr" RELEASE=1 PREFIX="/usr"
57+
58+
59+
# Build usrsctp
60+
ARG USRSCTP_VERSION="30d7f1bd0b58499e1e1f2415e84d76d951665dc8"
61+
ARG USRSCTP_FILE="${USRSCTP_VERSION}.tar.gz"
62+
ARG USRSCTP_EXTRACT="usrsctp-${USRSCTP_VERSION}"
63+
ARG USRSCTP_URL="https://github.com/sctplab/usrsctp/archive/${USRSCTP_FILE}"
64+
65+
RUN wget -O - ${USRSCTP_URL} | tar xz && \
66+
mv ${USRSCTP_EXTRACT} usrsctp && \
67+
cd usrsctp && \
68+
./bootstrap && \
69+
./configure --prefix="/usr/local" --libdir=/usr/local/lib/x86_64-linux-gnu && \
70+
make && \
71+
make install
72+
73+
74+
# Build libsrtp2
75+
ARG SRTP2_VER="2.1.0"
76+
ARG SRTP2_REPO=https://codeload.github.com/cisco/libsrtp/tar.gz/v${SRTP2_VER}
77+
78+
RUN apt-get update && apt-get install -y -q --no-install-recommends curl
79+
80+
RUN curl -o libsrtp-${SRTP2_VER}.tar.gz ${SRTP2_REPO} && \
81+
tar xzf libsrtp-${SRTP2_VER}.tar.gz && \
82+
cd libsrtp-${SRTP2_VER} && \
83+
export PKG_CONFIG_PATH="/usr/local/lib/x86_64-linux-gnu/pkgconfig" && \
84+
export CFLAGS="-fPIC" && \
85+
./configure --enable-openssl --prefix="/usr/local" --with-openssl-dir="/usr/local" && \
86+
make -s V=0 && \
87+
make install
88+
89+
90+
# Fetch FFmpeg source
91+
ARG FFMPEG_VER="4.1.3"
92+
ARG FFMPEG_DIR="ffmpeg-${FFMPEG_VER}"
93+
ARG FFMPEG_SRC="${FFMPEG_DIR}.tar.bz2"
94+
ARG FFMPEG_SRC_URL="http://ffmpeg.org/releases/${FFMPEG_SRC}"
95+
ARG FFMPEG_SRC_MD5SUM="9985185a8de3678e5b55b1c63276f8b5"
96+
97+
RUN wget ${FFMPEG_SRC_URL} && tar xf ${FFMPEG_SRC} && mv ${FFMPEG_DIR} FFmpeg && \
98+
cd FFmpeg ;
99+
# Compile FFmpeg
100+
RUN cd /home/FFmpeg && \
101+
export PKG_CONFIG_PATH="/usr/local/lib/x86_64-linux-gnu/pkgconfig" && \
102+
./configure --prefix="/usr/local" --libdir=/usr/local/lib/x86_64-linux-gnu --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype && \
103+
make -j8 && \
104+
make install
105+
106+
107+
# Install node
108+
ARG NODE_VER=v8.15.0
109+
ARG NODE_REPO=https://nodejs.org/dist/${NODE_VER}/node-${NODE_VER}-linux-x64.tar.xz
110+
111+
RUN wget ${NODE_REPO} && \
112+
tar xf node-${NODE_VER}-linux-x64.tar.xz && \
113+
cp node-*/* /usr/local -rf && rm -rf node-*
114+
115+
116+
# Fetch SVT-HEVC
117+
ARG SVT_HEVC_VER=v1.3.0
118+
ARG SVT_HEVC_REPO=https://github.com/intel/SVT-HEVC
119+
120+
RUN git clone ${SVT_HEVC_REPO} && \
121+
cd SVT-HEVC/Build/linux && \
122+
export PKG_CONFIG_PATH="/usr/local/lib/x86_64-linux-gnu/pkgconfig" && \
123+
git checkout ${SVT_HEVC_VER} && \
124+
mkdir -p ../../Bin/Release && \
125+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu -DCMAKE_ASM_NASM_COMPILER=yasm ../.. && \
126+
make -j8 && \
127+
make install
128+
129+
130+
# Install json_hpp
131+
ARG JSON_VER=v3.6.1
132+
ARG JSON_LINK=https://github.com/nlohmann/json/releases/download/${JSON_VER}/json.hpp
133+
134+
RUN wget -c ${JSON_LINK} && mv json.hpp /usr/include/
135+
136+
137+
# Build OWT specific modules
138+
ARG OWTSERVER_REPO=https://github.com/open-webrtc-toolkit/owt-server.git
139+
ARG OPENH264_MAJOR=1
140+
ARG OPENH264_MINOR=7
141+
ARG OPENH264_SOVER=4
142+
ARG OPENH264_SOURCENAME=v${OPENH264_MAJOR}.${OPENH264_MINOR}.0.tar.gz
143+
ARG OPENH264_SOURCE=https://github.com/cisco/openh264/archive/v${OPENH264_MAJOR}.${OPENH264_MINOR}.0.tar.gz
144+
ARG OPENH264_BINARYNAME=libopenh264-${OPENH264_MAJOR}.${OPENH264_MINOR}.0-linux64.${OPENH264_SOVER}.so
145+
ARG OPENH264_BINARY=https://github.com/cisco/openh264/releases/download/v${OPENH264_MAJOR}.${OPENH264_MINOR}.0/${OPENH264_BINARYNAME}.bz2
146+
ARG LICODE_COMMIT="8b4692c88f1fc24dedad66b4f40b1f3d804b50ca"
147+
ARG LICODE_REPO=https://github.com/lynckia/licode.git
148+
ARG WEBRTC_REPO=https://github.com/open-webrtc-toolkit/owt-deps-webrtc.git
149+
ARG SVT_VER=v1.3.0
150+
ARG SVT_REPO=https://github.com/intel/SVT-HEVC.git
151+
ARG SERVER_PATH=/home/owt-server
152+
ARG OWT_SDK_REPO=https://github.com/open-webrtc-toolkit/owt-client-javascript.git
153+
ARG OWT_BRANCH=master
10154
ARG IMG_APP_PATH=/app_data/
11155
ENV APP_PATH=${IMG_APP_PATH}
12156

13-
# Update the system
14-
RUN apt-get update
157+
RUN apt-get update && apt-get install -y -q --no-install-recommends python libglib2.0-dev rabbitmq-server mongodb libboost-thread-dev libboost-system-dev liblog4cxx-dev
158+
159+
# 1. Clone OWT server source code
160+
# 2. Clone licode source code and patch
161+
# 3. Clone webrtc source code and patch
162+
RUN git config --global user.email "[email protected]" && \
163+
git config --global user.name "Your Name" && \
164+
git clone --depth=1 -b ${OWT_BRANCH} ${OWTSERVER_REPO} && \
165+
166+
# Install node modules for owt
167+
npm install -g --loglevel error node-gyp grunt-cli underscore jsdoc && \
168+
cd owt-server && npm install nan && \
169+
170+
# Get openh264 for owt
171+
cd third_party && \
172+
mkdir openh264 && cd openh264 && \
173+
wget ${OPENH264_SOURCE} && \
174+
wget ${OPENH264_BINARY} && \
175+
tar xzf ${OPENH264_SOURCENAME} openh264-${OPENH264_MAJOR}.${OPENH264_MINOR}.0/codec/api && \
176+
ln -s -v openh264-${OPENH264_MAJOR}.${OPENH264_MINOR}.0/codec codec && \
177+
bzip2 -d ${OPENH264_BINARYNAME}.bz2 && \
178+
ln -s -v ${OPENH264_BINARYNAME} libopenh264.so.${OPENH264_SOVER} && \
179+
ln -s -v libopenh264.so.${OPENH264_SOVER} libopenh264.so && \
180+
echo 'const char* stub() {return "this is a stub lib";}' > pseudo-openh264.cpp && \
181+
gcc pseudo-openh264.cpp -fPIC -shared -o pseudo-openh264.so
182+
183+
# Get licode for owt
184+
RUN cd ${SERVER_PATH}/third_party && git clone ${LICODE_REPO} && \
185+
cd licode && \
186+
git reset --hard ${LICODE_COMMIT} && \
187+
git am ${SERVER_PATH}/scripts/patches/licode/*.patch
188+
189+
# Install webrtc for owt
190+
RUN cd ${SERVER_PATH}/third_party && mkdir webrtc && cd webrtc &&\
191+
export GIT_SSL_NO_VERIFY=1 && \
192+
git clone -b 59-server ${WEBRTC_REPO} src && \
193+
./src/tools-woogeen/install.sh && \
194+
./src/tools-woogeen/build.sh
195+
196+
# Install webrtc79 for owt
197+
RUN mkdir ${SERVER_PATH}/third_party/webrtc-m79 && \
198+
cd ${SERVER_PATH}/third_party/webrtc-m79 && \
199+
/bin/bash ${SERVER_PATH}/scripts/installWebrtc.sh
15200

16-
# Install utils
17-
RUN apt-get install -y ca-certificates git lsb-release mongodb nodejs npm sudo wget
201+
# Get js client sdk for owt
202+
RUN cd /home && git clone --depth=1 -b ${OWT_BRANCH} ${OWT_SDK_REPO} && cd owt-client-javascript/scripts && npm install && grunt && \
203+
mkdir ${SERVER_PATH}/third_party/quic-lib && \
204+
export LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu && \
205+
cd ${SERVER_PATH}/third_party/quic-lib && wget https://github.com/open-webrtc-toolkit/owt-deps-quic/releases/download/v0.1/dist.tgz && tar xzf dist.tgz && \
206+
#Build and pack owt
207+
cd ${SERVER_PATH} && export PKG_CONFIG_PATH=/usr/local/lib/x86_64-linux-gnu/pkgconfig && ./scripts/build.js -t mcu-all -r -c && \
208+
./scripts/pack.js -t all --install-module --no-pseudo --app-path /home/owt-client-javascript/dist/samples/conference
18209

19-
RUN npm install -g grunt-cli node-gyp
20210

21-
# Keep proxy environment for sudo
22-
RUN bash -c "echo \"Defaults env_keep = \\\"http_proxy https_proxy no_proxy \\\"\" >> /etc/sudoers"
23-
RUN wget https://github.com/Intel-Media-SDK/MediaSDK/releases/download/intel-mediasdk-$MEDIA_SDK_VER/MediaStack.tar.gz -P /tmp
24-
RUN cd /tmp && tar -zxf MediaStack.tar.gz && cd MediaStack && ./install_media.sh
25-
RUN rm /tmp/MediaStack.tar.gz && rm -rf /tmp/MediaStack
26-
ENV MFX_HOME=/opt/intel/mediasdk
211+
FROM ubuntu:18.04 AS owt-run
212+
LABEL Description="This is the image for building OWT on Ubuntu 18.04"
213+
LABEL Vendor="Intel Corporation"
214+
WORKDIR /home
27215

28-
RUN git clone https://github.com/open-webrtc-toolkit/owt-server.git --depth=1
29-
RUN mkdir -p ${APP_PATH}
216+
# Prerequisites
217+
# Install node
218+
ARG NODE_VER=v8.15.0
219+
ARG NODE_REPO=https://nodejs.org/dist/${NODE_VER}/node-${NODE_VER}-linux-x64.tar.xz
30220

31-
WORKDIR /owt-server
221+
COPY --from=owt-build /home/owt-server/dist /home/owt
222+
COPY startowt.sh /home/
32223

33-
# This is needed to patch licode
34-
RUN git config --global user.email "[email protected]" && \
35-
git config --global user.name "Your Name"
224+
RUN apt-get update && apt-get install -y -q --no-install-recommends ca-certificates wget xz-utils rabbitmq-server mongodb libboost-system-dev libboost-thread-dev liblog4cxx-dev libglib2.0-0 libfreetype6-dev curl
36225

37-
RUN ./scripts/installDepsUnattended.sh
226+
RUN wget ${NODE_REPO} && \
227+
tar xf node-${NODE_VER}-linux-x64.tar.xz && \
228+
cp node-*/* /usr/local -rf && rm -rf node-*
38229

39-
# Set workpath to where the app should be installed for the next step of the multibuild
40-
WORKDIR ${APP_PATH}
230+
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/x86_64-linux-gnu

docker/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
This document is used for generating OWT build and all-in-one OWT running environment images.
2+
3+
## Prequisites
4+
5+
* Docker is setup in your local environment and related proxy is set so that Docker can access to external network (including Google because OWT will download WebRTC related code and patch from Google)
6+
7+
## Build OWT images
8+
9+
1. Run following command to generate Docker image containing OWT source code and dependencies. A dist folder will be generated with all OWT running binaries. You can run OWT service using this image directly in case you want to modify OWT source code and debug.
10+
11+
```shell
12+
docker build --target owt-build -t owt:build \
13+
--build-arg http_proxy=${HTTP_PROXY} \
14+
--build-arg https_proxy=${HTTPS_PROXY} \
15+
.
16+
```
17+
The default sample web app will be packed into the OWT package, you can modify Dockerfile to copy your own web app into the image and specify your app path in pack.js:
18+
19+
```
20+
./scripts/pack.js -t all --install-module --no-pseudo --app-path /home/owt-client-javascript/dist/samples/conference
21+
```
22+
Or you can refer conference/build_server.sh to see how to use docker swarm to pack your app into image.
23+
24+
2. Run following command to generate OWT running environment Docker image with OWT binaries generated in step 1, not including source code.
25+
```shell
26+
docker build --target owt-run -t owt:run \
27+
--build-arg http_proxy=${HTTP_PROXY} \
28+
--build-arg https_proxy=${HTTPS_PROXY} \
29+
.
30+
```
31+
Or you can simply run `build_docker_image.sh` to generate both 2 images.
32+
We provide a `startowt.sh` to launch OWT and expose following parameters to configure:
33+
34+
```
35+
--rabbit rabbitmq server address if rabbitmq service is deployed on a different device
36+
--mongo mongodb server address if mongo service is deployed on a different device, like --mongo=xx.xx.xx.xx/owtdb
37+
--externalip external ip of host device if there are internal and external ip for host device
38+
--network_interface network interface for external ip of host device if there are external and internal ip for host device
39+
```
40+
Note that `externalip` and `network_interface` should be both set if there are external and internal ip on host device. `startowt.sh` is just a reference, you can customize Dockerfile and script to generate the Docker images for cluster deployment. For example, separate each OWT modules into different Docker images.
41+
42+
2. Launch OWT service
43+
44+
a) Launch a Docker container with following command to simply try OWT:
45+
46+
```shell
47+
docker run -itd --name=owt --net=host owt:run /home/startowt.sh
48+
```
49+
Then OWT service should be launched and you can connect to https://localhost:3004 to start your OWT journey.
50+
51+
b) Launch OWT service with Docker swarm with script ```conference/build_server.sh```
52+
53+
c) Customize different OWT module images and launch OWT service with Kubernetes.

docker/build_docker_image.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
docker build --target owt-build -t owt:build \
4+
--build-arg http_proxy=${HTTP_PROXY} \
5+
--build-arg https_proxy=${HTTPS_PROXY} \
6+
.
7+
8+
docker build --target owt-run -t owt:run \
9+
--build-arg http_proxy=${HTTP_PROXY} \
10+
--build-arg https_proxy=${HTTPS_PROXY} \
11+
.

docker/startowt.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
# change workdir
4+
cd /home/owt
5+
6+
mongourl=localhost/owtdb
7+
LOG=/dev/null
8+
9+
service mongodb start &
10+
service rabbitmq-server start &
11+
12+
while ! mongo --quiet --eval "db.adminCommand('listDatabases')" >>$LOG 2>&1
13+
do
14+
echo mongo is not ready. Waiting
15+
sleep 1
16+
done
17+
18+
while ! rabbitmqctl -q status >> $LOG 2>&1
19+
do
20+
echo RabbitMQ is not ready. Waiting...
21+
sleep 1
22+
done
23+
24+
# format the parameters
25+
set -- $(getopt -u -l rabbit:,mongo:,hostname:,externalip:,network_interface:: -- -- "$@")
26+
# get the parameters
27+
while [ -n "$1" ]
28+
do
29+
case "$1" in
30+
--rabbit ) rabbitmqip=$2; shift; shift ;;
31+
--mongo ) mongourl=$2; shift; shift ;;
32+
--hostname ) hostname=$2; shift; shift ;;
33+
--externalip ) externalip=$2; shift; shift ;;
34+
--network_interface ) networkinterface=$2; shift; shift ;;
35+
* ) break;;
36+
esac
37+
done
38+
39+
alltoml=$(find . -maxdepth 2 -name "*.toml")
40+
echo ${mongourl}
41+
echo ${rabbitmqip}
42+
for toml in $alltoml; do
43+
if [ ! -z "${mongourl}" ];then
44+
sed -i "/^dataBaseURL = /c \dataBaseURL = \"${mongourl}\"" $toml
45+
fi
46+
47+
if [ ! -z "${rabbitmqip}" ];then
48+
if [[ $toml == *"management_console"* ]]; then
49+
echo "Do not modify management_console"
50+
else
51+
sed -i "/^host = /c \host = \"${rabbitmqip}\"" $toml
52+
fi
53+
54+
fi
55+
done
56+
57+
if [ ! -z "${hostname}" ];then
58+
echo ${hostname}
59+
sed -i "/^hostname = /c \hostname = \"${hostname}\"" portal/portal.toml
60+
fi
61+
62+
if [ ! -z "${externalip}" ] && [ ! -z "{network_interface}" ];then
63+
echo ${externalip}
64+
sed -i "/^network_interfaces =/c \network_interfaces = [{name = \"${networkinterface}\", replaced_ip_address = \"${externalip}\"}]" webrtc_agent/agent.toml
65+
sed -i "/^ip_address = /c \ip_address = \"${externalip}\"" portal/portal.toml
66+
fi
67+
68+
./management_api/init.sh --dburl=${mongourl}
69+
70+
./video_agent/install_openh264.sh
71+
72+
./bin/start-all.sh
73+
74+
sleep infinity

0 commit comments

Comments
 (0)