-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c338331
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# chrome-docker | ||
|
||
A dockerfile that is based on Ubuntu image that can run standalone chrome which can be opened via vnc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: "3.0" | ||
|
||
services: | ||
chrome: | ||
build: | ||
context: . | ||
container_name: chrome-ubuntu | ||
ports: | ||
- 5900:5900 | ||
privileged: true | ||
user: apps | ||
environment: | ||
- VNC_SERVER_PASSWORD=1234 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM ubuntu:18.04 | ||
|
||
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 | ||
|
||
# Install gnupg. | ||
RUN apt-get install -y gnupg | ||
|
||
# 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 entrypoint.sh / | ||
|
||
CMD '/entrypoint.sh' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/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 | ||
|
||
exit |