openvidu-recording Firefox container fix display num

pull/508/head
pabloFuente 2020-07-09 15:09:20 +02:00
parent 5124e32a1d
commit 4ac3f4beff
4 changed files with 36 additions and 41 deletions

View File

@ -1,21 +1,24 @@
FROM ubuntu:16.04
FROM ubuntu:20.04
MAINTAINER openvidu@gmail.com
# Install packages
RUN apt-get update && apt-get -y upgrade && apt-get install -y \
wget \
sudo \
gnupg2 \
apt-utils \
software-properties-common \
ffmpeg \
pulseaudio \
xvfb \
jq \
&& rm -rf /var/lib/apt/lists/*
# Install Firefox
RUN apt-get update && apt-get -y upgrade && apt-get install -y wget sudo
RUN apt-get install -y firefox
RUN apt-get update && apt-get -y upgrade && apt-get install -y firefox
# Install media packages
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:jonathonf/ffmpeg-4
RUN apt-get update
RUN apt-get install -y ffmpeg pulseaudio xvfb
# Install jq for managing JSON
RUN apt-get install -y jq
# Clean
RUN apt-get autoclean
# Clean
RUN apt-get clean && apt-get autoclean && apt-get autoremove
COPY entrypoint.sh /entrypoint.sh
COPY configuration/autoconfig.js /usr/lib/firefox/defaults/pref/autoconfig.js

View File

@ -5,4 +5,6 @@ lockPref("extensions.autoDisableScopes", 0);
lockPref("extensions.enabledScopes", 15);
lockPref("security.ssl.enable_ocsp_stapling", false);
lockPref("network.stricttransportsecurity.preloadlist", false);
lockPref("network.http.phishy-userpass-length", 300);
lockPref("network.http.phishy-userpass-length", 300);
lockPref("security.enterprise_roots.enabled", true);
lockPref("network.websocket.allowInsecureFromHTTPS", true);

View File

@ -1 +1 @@
docker build --rm -t openvidu/openvidu-recording:2.10.0-firefox .
docker build --rm -t openvidu/openvidu-recording:2.15.0-firefox .

View File

@ -30,38 +30,28 @@ mkdir /recordings/$VIDEO_ID
chmod 777 /recordings/$VIDEO_ID
echo $RECORDING_JSON > /recordings/$VIDEO_ID/.recording.$VIDEO_ID
### Get a free display identificator ###
DISPLAY_NUM=99
DONE="no"
while [ "$DONE" == "no" ]
do
out=$(xdpyinfo -display :$DISPLAY_NUM 2>&1)
if [[ "$out" == name* ]] || [[ "$out" == Invalid* ]]
then
# Command succeeded; or failed with access error; display exists
(( DISPLAY_NUM+=1 ))
else
# Display doesn't exist
DONE="yes"
fi
done
export DISPLAY_NUM
echo "First available display -> :$DISPLAY_NUM"
echo "----------------------------------------"
pulseaudio -D
### Start Chrome in headless mode with xvfb, using the display num previously obtained ###
### Start Chrome in headless mode with xvfb, using an automatically provided free display num ###
touch xvfb.log
chmod 777 xvfb.log
xvfb-run --server-num=${DISPLAY_NUM} --server-args="-ac -screen 0 ${RESOLUTION}x24 -noreset" firefox --width $WIDTH --height $HEIGHT $URL &> xvfb.log &
xvfb-run --auto-servernum --server-args="-ac -screen 0 ${RESOLUTION}x24 -noreset" firefox --width $WIDTH --height $HEIGHT $URL &> xvfb.log &
touch stop
chmod 777 /recordings
until pids=$(pidof Xvfb)
do
sleep 0.1
done
### Calculate the display num in use parsing args of command "Xvfb"
XVFB_ARGS=$(ps -eo args | grep [X]vfb)
DISPLAY_NUM=$(echo $XVFB_ARGS | sed 's/Xvfb :\([0-9]\+\).*/\1/')
echo "Display in use -> :$DISPLAY_NUM"
echo "----------------------------------------"
sleep 5
### Start recording with ffmpeg ###