init
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
FROM siomiz/chrome
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
RUN apt-get install -y libasound2 alsa-utils alsa-oss
|
||||
|
||||
RUN apt-get install -y pulseaudio
|
||||
@@ -0,0 +1,35 @@
|
||||
FROM ubuntu:xenial
|
||||
|
||||
RUN apt-get update; apt-get clean
|
||||
|
||||
# Add a user for running applications.
|
||||
RUN useradd apps
|
||||
RUN mkdir -p /home/apps && chown apps:apps /home/apps
|
||||
|
||||
# Install x11vnc.
|
||||
RUN apt-get install -y x11vnc
|
||||
|
||||
# Install xvfb.
|
||||
RUN apt-get install -y xvfb
|
||||
|
||||
# Install fluxbox.
|
||||
RUN apt-get install -y fluxbox
|
||||
|
||||
# Install wget.
|
||||
RUN apt-get install -y wget
|
||||
|
||||
# Install wmctrl.
|
||||
RUN apt-get install -y wmctrl
|
||||
|
||||
RUN apt-get install -y gnupg2
|
||||
|
||||
# Set the Chrome repo.
|
||||
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
|
||||
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
|
||||
|
||||
# Install Chrome.
|
||||
RUN apt-get update && apt-get -y install google-chrome-stable
|
||||
|
||||
COPY bootstrap.sh /
|
||||
|
||||
CMD '/bootstrap.sh'
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Based on: http://www.richud.com/wiki/Ubuntu_Fluxbox_GUI_with_x11vnc_and_Xvfb
|
||||
|
||||
readonly G_LOG_I='[INFO]'
|
||||
readonly G_LOG_W='[WARN]'
|
||||
readonly G_LOG_E='[ERROR]'
|
||||
|
||||
main() {
|
||||
launch_xvfb
|
||||
launch_window_manager
|
||||
run_vnc_server
|
||||
}
|
||||
|
||||
launch_xvfb() {
|
||||
# Set defaults if the user did not specify envs.
|
||||
export DISPLAY=${XVFB_DISPLAY:-:1}
|
||||
local screen=${XVFB_SCREEN:-0}
|
||||
local resolution=${XVFB_RESOLUTION:-1280x1024x24}
|
||||
local timeout=${XVFB_TIMEOUT:-5}
|
||||
|
||||
# Start and wait for either Xvfb to be fully up or we hit the timeout.
|
||||
Xvfb ${DISPLAY} -screen ${screen} ${resolution} &
|
||||
local loopCount=0
|
||||
until xdpyinfo -display ${DISPLAY} > /dev/null 2>&1
|
||||
do
|
||||
loopCount=$((loopCount+1))
|
||||
sleep 1
|
||||
if [ ${loopCount} -gt ${timeout} ]
|
||||
then
|
||||
echo "${G_LOG_E} xvfb failed to start."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
launch_window_manager() {
|
||||
local timeout=${XVFB_TIMEOUT:-5}
|
||||
|
||||
# Start and wait for either fluxbox to be fully up or we hit the timeout.
|
||||
fluxbox &
|
||||
local loopCount=0
|
||||
until wmctrl -m > /dev/null 2>&1
|
||||
do
|
||||
loopCount=$((loopCount+1))
|
||||
sleep 1
|
||||
if [ ${loopCount} -gt ${timeout} ]
|
||||
then
|
||||
echo "${G_LOG_E} fluxbox failed to start."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
run_vnc_server() {
|
||||
local passwordArgument='-nopw'
|
||||
|
||||
if [ -n "${VNC_SERVER_PASSWORD}" ]
|
||||
then
|
||||
local passwordFilePath="${HOME}/x11vnc.pass"
|
||||
if ! x11vnc -storepasswd "${VNC_SERVER_PASSWORD}" "${passwordFilePath}"
|
||||
then
|
||||
echo "${G_LOG_E} Failed to store x11vnc password."
|
||||
exit 1
|
||||
fi
|
||||
passwordArgument=-"-rfbauth ${passwordFilePath}"
|
||||
echo "${G_LOG_I} The VNC server will ask for a password."
|
||||
else
|
||||
echo "${G_LOG_W} The VNC server will NOT ask for a password."
|
||||
fi
|
||||
|
||||
x11vnc -display ${DISPLAY} -forever ${passwordArgument} &
|
||||
wait $!
|
||||
}
|
||||
|
||||
control_c() {
|
||||
echo ""
|
||||
exit
|
||||
}
|
||||
|
||||
#trap control_c SIGINT SIGTERM SIGHUP
|
||||
|
||||
main
|
||||
|
||||
sleep 1
|
||||
google-chrome --start-maximized --no-first-run --display ${DISPLAY}
|
||||
|
||||
exit
|
||||
@@ -0,0 +1,16 @@
|
||||
import http from "node:http";
|
||||
import net from "node:net";
|
||||
|
||||
const port = 5902;
|
||||
|
||||
const client = new net.Socket();
|
||||
const server = http.createServer((req, res) => {
|
||||
console.log(req.url);
|
||||
res.setHeader("Content-Type", "audio/ogg");
|
||||
client.connect(5901, "localhost");
|
||||
client.pipe(res);
|
||||
});
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log(`server is listening on ${port}`);
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
# Enable kernel modules on the host
|
||||
modprobe snd-aloop
|
||||
|
||||
# Install gstreamer
|
||||
apt-get install -y libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
|
||||
|
||||
# Inside container: ALSA to view sound devices with aplay -l
|
||||
apt-get install -y libasound2 alsa-utils alsa-oss
|
||||
apt-get install -y pulseaudio
|
||||
|
||||
# Rebuild our container
|
||||
docker build . -t browseparty/chrome
|
||||
|
||||
# Run our services
|
||||
# Start chrome + VNC, sharing audio device
|
||||
docker run -d -p 5900:5900 --rm --name chrome --device /dev/snd -e VNC_PASSWORD="password" -e VNC_SCREEN_SIZE="1280x720" -e CHROME_OPTS_OVERRIDE=" --user-data-dir --no-sandbox --no-first-run --window-position=0,0 --force-device-scale-factor=1 --disable-dev-shm-usage" browseparty/chrome
|
||||
|
||||
# Proxy the VNC from TCP to WebSocket
|
||||
docker run -d -it --rm --net=host --name websockify efrecon/websockify 5000 localhost:5900
|
||||
|
||||
# Audio test
|
||||
speaker-test -D hw:0,0,0 --channels 2 --rate 48000
|
||||
|
||||
# Stream the audio to a TCP sink
|
||||
gst-launch-1.0 -v alsasrc device=hw:0,1,0 ! audio/x-raw, channels=2, rate=48000 ! opusenc complexity=0 ! oggmux ! tcpserversink port=5901 host=0.0.0.0
|
||||
gst-launch-1.0 -v alsasrc device=hw:0,1,0 ! audio/x-raw, channels=2, rate=48000 ! audioconvert ! lamemp3enc ! tcpserversink port=5901 host=0.0.0.0
|
||||
|
||||
# Proxy the audio from TCP to WebSocket
|
||||
docker run -d -it --rm --net=host --name websockify-audio efrecon/websockify 5001 localhost:5901
|
||||
Reference in New Issue
Block a user