This is a record of the procedure for building a Docker container image of Janus of WebRTC. The constructed Docker container image will be published on Docker Hub. If you want to try the Docker container image created in this procedure immediately, follow the procedure of Launch Janus service from public image of Docker Hub.
MacBook Air (M1, 2020) Mac OS Big Sur 11.0.1 PREVIEW version for Docker Desktop Silicon MAC Container base image: Debian
#Get container image
$docker pull debian
#Container startup
$docker run -itd debian /bin/sh
#Confirm container ID
$docker ps -a
#Shell into the container
$docker exec -it container ID bash
#update
$apt-get update
#Required library installation
$apt install libmicrohttpd-dev libjansson-dev libssl-dev \
libsofia-sip-ua-dev libglib2.0-dev libopus-dev libogg-dev \
libcurl4-openssl-dev liblua5.3-dev libconfig-dev \
pkg-config gengetopt libtool automake gtk-doc-tools doxygen \
graphviz libnanomsg-dev cmake -y --fix-missing
#Install the command used for installation
$apt-get install -y wget && \
apt-get install vim -y && \
apt-get install git -y && \
apt-get install -y curl
#libnice
$PATH="/usr/local/bin:$PATH"
$apt install python3-pip
$pip3 install meson
$pip3 install ninja
$cd ~
$git clone https://gitlab.freedesktop.org/libnice/libnice
$cd libnice
$meson --prefix=/usr build && ninja -C build && ninja -C build install
#libsrtp
$cd ~
$wget https://github.com/cisco/libsrtp/archive/v2.2.0.tar.gz
$tar xfv v2.2.0.tar.gz
$cd libsrtp-2.2.0
$./configure --prefix=/usr --enable-openssl
$make shared_library && make install
#usrsctp
$cd ~
$git clone https://github.com/sctplab/usrsctp
$cd usrsctp
$./bootstrap
$./configure --prefix=/usr --disable-programs --disable-inet --disable-inet6
$make && make install
#libwebsockets
$cd ~
$git clone https://libwebsockets.org/repo/libwebsockets
$cd libwebsockets
$mkdir build
$cd build
$cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 \
-DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
$make && make install
$cd ~
$git clone https://github.com/meetecho/janus-gateway.git
$cd janus-gateway
$sh autogen.sh
$./configure --prefix=/opt/janus
$make
$make install
$make configs
#Service start
$/opt/janus/bin/janus&
#Confirm that there is a Json response of the Janus server with the curl command
$curl http://localhost:8088/janus/info
#end janus process
$ps aux | grep janus | grep -v grep | awk '{ print "kill -9", $2 }' | sh
#node,npm install
$apt-get install nodejs npm
#Since the version of npm is old, install the latest version with version control
$npm install n -g
$n stable
#Remove old nodejs npm version
$apt purge -y nodejs npm
#Reboot the shell
$exec $SHELL -l
#Check version
$node -v
#Simple web server (local-web-server) installation
$npm install -g local-web-server
$cd ~/janus-gateway
$touch run_janus.sh
$echo "/opt/janus/bin/janus &" >>run_janus.sh
$echo "cd /root/janus-gateway/html" >>run_janus.sh
$echo "ws&" >>run_janus.sh
$chmod 755 run_janus.sh
#Janus server starts demo
$~/janus-gateway/run_janus.sh
#Janus server, demo operation check
$curl http://localhost:8000
$curl http://localhost:8088/janus/info
#Exit the container and return to the console on the host side
$exit
Create a container image on the host side.
#Confirmation of the container ID you were working on
$docker ps -a
#Stop container to create image
$docker stop container ID
#Container image creation
$docker commit container ID janus
#Delete the container you were working on
$docker rm container ID
$docker run -itd -p 8088:8088 -p 8000:8000 --name janus janus \
/bin/bash -c "/root/janus-gateway/run_janus.sh;/bin/sh"
Port forward with "-p 8088: 8088 -p 8000: 8000" so that the Janus server and client services can be accessed from the browser in the local environment. Execute the startup shell with "/ bin/bash -c" so that the Janus server and client are started when the container is started.
Access the demo page (http://127.0.0.1:8000/videoroomtest.html
) from your browser and check that Janus's video room etc. can be used.
Click the START button on the upper right and enter the room name, and the camera image of your computer will be displayed on the browser.
#Confirmation of the container ID you were working on
$docker ps -a
#Stop container to create image
$docker stop container ID
#Log in to Docker Hub (enter user and password)
$docker login
#Docker image creation
$docker commit container ID pyuta/janus-local-run:latest
#Check the image ID of the Docker image
$docker images
#Push to Docker Hub
$docker push pyuta/janus-local-run:latest
$docker run -itd -p 8088:8088 -p 8000:8000 --name janus \
pyuta/janus-local-run:latest \
/bin/bash -c "/root/janus-gateway/run_janus.sh;/bin/sh"
Access the demo page (http://127.0.0.1:8000/videoroomtest.html
) from your browser and check that Janus's video room etc. can be used.
Click the START button on the upper right and enter the room name, and the camera image of your computer will be displayed on the browser.
Now that we have containerized the Janus service in our local Docker environment, our next goal is to create a container image that can be used directly and externally.
** Addendum ** I made the described procedure into a Dockerfile. Publish with Create Web RTC Janus container with Dockerfile -Qiita.
Recommended Posts