Skip to content

Commit 61702ad

Browse files
committed
first commit
0 parents  commit 61702ad

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM ubuntu
2+
3+
RUN apt-get update; apt-get clean
4+
5+
# Add a user for running applications.
6+
RUN useradd apps
7+
RUN mkdir -p /home/apps && chown apps:apps /home/apps
8+
9+
# Install x11vnc.
10+
RUN apt-get install -y x11vnc
11+
12+
# Install xvfb.
13+
RUN apt-get install -y xvfb
14+
15+
# Install fluxbox.
16+
RUN apt-get install -y fluxbox
17+
18+
# Install wget.
19+
RUN apt-get install -y wget
20+
21+
# Install wmctrl.
22+
RUN apt-get install -y wmctrl
23+
24+
# Set the Chrome repo.
25+
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
26+
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
27+
28+
# Install Chrome.
29+
RUN apt-get update && apt-get -y install google-chrome-stable
30+
31+
COPY bootstrap.sh /
32+
RUN chown apps:apps /bootstrap.sh
33+
RUN chmod 744 /bootstrap.sh
34+
35+
CMD '/bootstrap.sh'
36+

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# docker-chrome

bootstrap.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
3+
# Based on: http://www.richud.com/wiki/Ubuntu_Fluxbox_GUI_with_x11vnc_and_Xvfb
4+
5+
echo "Hello"
6+
7+
readonly G_LOG_I='[INFO]'
8+
readonly G_LOG_W='[WARN]'
9+
readonly G_LOG_E='[ERROR]'
10+
11+
main() {
12+
launch_xvfb
13+
launch_window_manager
14+
run_vnc_server
15+
}
16+
17+
launch_xvfb() {
18+
# Set defaults if the user did not specify envs.
19+
export DISPLAY=${XVFB_DISPLAY:-:1}
20+
local screen=${XVFB_SCREEN:-0}
21+
local resolution=${XVFB_RESOLUTION:-1024x768x24}
22+
local timeout=${XVFB_TIMEOUT:-5}
23+
24+
# Start and wait for either Xvfb to be fully up or we hit the timeout.
25+
Xvfb ${DISPLAY} -screen ${screen} ${resolution} &
26+
local loopCount=0
27+
until xdpyinfo -display ${DISPLAY} > /dev/null 2>&1
28+
do
29+
loopCount=$((loopCount+1))
30+
sleep 1
31+
if [ ${loopCount} -gt ${timeout} ]
32+
then
33+
echo "${G_LOG_E} xvfb failed to start."
34+
exit 1
35+
fi
36+
done
37+
}
38+
39+
launch_window_manager() {
40+
local timeout=${XVFB_TIMEOUT:-5}
41+
42+
# Start and wait for either fluxbox to be fully up or we hit the timeout.
43+
fluxbox &
44+
local loopCount=0
45+
until wmctrl -m > /dev/null 2>&1
46+
do
47+
loopCount=$((loopCount+1))
48+
sleep 1
49+
if [ ${loopCount} -gt ${timeout} ]
50+
then
51+
echo "${G_LOG_E} fluxbox failed to start."
52+
exit 1
53+
fi
54+
done
55+
}
56+
57+
run_vnc_server() {
58+
local passwordArgument='-nopw'
59+
60+
if [ -n "${VNC_SERVER_PASSWORD}" ]
61+
then
62+
local passwordFilePath="${HOME}/x11vnc.pass"
63+
if ! x11vnc -storepasswd "${VNC_SERVER_PASSWORD}" "${passwordFilePath}"
64+
then
65+
echo "${G_LOG_E} Failed to store x11vnc password."
66+
exit 1
67+
fi
68+
passwordArgument=-"-rfbauth ${passwordFilePath}"
69+
echo "${G_LOG_I} The VNC server will ask for a password."
70+
else
71+
echo "${G_LOG_W} The VNC server will NOT ask for a password."
72+
fi
73+
74+
x11vnc -display ${DISPLAY} -forever ${passwordArgument} &
75+
wait $!
76+
}
77+
78+
control_c() {
79+
echo ""
80+
exit
81+
}
82+
83+
trap control_c SIGINT SIGTERM SIGHUP
84+
85+
main
86+
87+
exit
88+

0 commit comments

Comments
 (0)