Skip to content
......@@ -16,6 +16,8 @@ RUN apt-get install git curl sudo nano -y
RUN cd /opt/ && git clone https://github.com/lofar-astron/LOFARBeam.git
RUN mkdir /opt/LOFARBeam/build && cd /opt/LOFARBeam/build && cmake -DCMAKE_INSTALL_PREFIX=/opt/lofarsoft -DPYTHON_EXECUTABLE=$(which python) -DCASACORE_INCLUDE_DIRS=/opt/lofarsoft/include/casacore/ -DCASACORE_LIBRARIES=/opt/lofarsoft/lib/ -DCASACORE_ROOT_DIR=/opt/lofarsoft/ ../ && make -j16 && make install
#------------------------
# Lofar user
#------------------------
......@@ -37,10 +39,63 @@ COPY data/input_data /input_data
COPY data/output_data /output_data
RUN chown lofar:lofar /home/lofar && chown -R lofar:lofar /input_data && chown -R lofar:lofar /output_data
# This is required mainly for Singularity
RUN mv /home/lofar /home/vanilla_lofar
RUN ln -s /tmp/lofarhome /home/lofar
RUN rm -rf /tmp/lofarhome
#----------------------
# Minimal Desktop
#----------------------
# Utilities
RUN apt-get install -y telnet unzip wget supervisor build-essential python-dev git-core openjdk-8-jre
# Global Supervisord conf
COPY files/supervisord.conf /etc/supervisor/
# Install xvfb that triggers minimal install of X base packages and xterm
RUN apt-get install xvfb xterm -y
# Install base packages for VNC server and headless desktop (2)
RUN cd /opt && wget https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.8.0.x86_64.tar.gz -O tigervnc-1.8.0.x86_64.tar.gz \
&& tar -zxvf tigervnc-1.8.0.x86_64.tar.gz \
&& mv tigervnc-1.8.0.x86_64 tigervnc
# Supervisord configuration
COPY files/supervisord_vnc.conf /etc/supervisor/conf.d/
COPY files/run_vnc.sh /etc/supervisor/conf.d/
COPY files/run_novnc.sh /etc/supervisor/conf.d/
RUN chmod 755 /etc/supervisor/conf.d/run_vnc.sh
RUN chmod 755 /etc/supervisor/conf.d/run_novnc.sh
# Web VNC (noVNC) v0.6.1.
# NOTE: this is a custom version from Doro Wu (fcwu.tw@gmail.com).
# TODO: Check differences and maybe move to 0.6.2
COPY files/noVNC.tar.gz /usr/lib/
RUN cd /usr/lib/ && tar -zxvf noVNC.tar.gz
COPY files/index.html /usr/lib/noVNC
RUN apt-get install -y net-tools
# Supervisord configuration
COPY files/supervisord_novnc.conf /etc/supervisor/conf.d/
# X environment setup/startup
RUN apt-get install fluxbox -y
COPY files/xstartup /opt/tigervnc/
RUN chmod 755 /opt/tigervnc/xstartup
# Prepare for logs
RUN mkdir /home/lofar/.logs && chown lofar:lofar /home/lofar/.logs
# Add fluxbox customisations
COPY files/dot_fluxbox /home/lofar/.fluxbox
RUN chown -R lofar:lofar /home/lofar/.fluxbox
COPY files/background.jpg /usr/share/images/fluxbox/background.jpg
# Rename lofar home folder as a "vanilla" home folder
RUN mv /home/lofar /lofar_home_vanilla
# Give write access to anyone to the home folder so the entrypoint will be able
# to copy over the /home/matauser_vanilla into /home/lofar (for Singularity)
RUN chmod 777 /home
#----------------------
......
#!/bin/bash
# Exit on any error. More complex thing could be done in future
# Exit on any error. More complex stuff could be done in future
# (see https://stackoverflow.com/questions/4381618/exit-a-script-on-error)
set -e
echo ""
echo "[INFO] Executing entrypoint..."
#echo "[INFO] Sourcing env in /opt/lofarsoft/lofarinit.sh..."
source /opt/lofarsoft/lofarinit.sh
if [ "x$SAFE_MODE" == "xTrue" ]; then
echo "[INFO] Creating /tmp/lofarhome to be used as lofar home"
mkdir /tmp/lofarhome
echo ""
echo "[INFO] Not executing entrypoint as we are in safe mode, just opening a Bash shell."
exec /bin/bash
echo "[INFO] Initialising /tmp/lofarhome with configuration files"
cp -aT /home/vanilla_lofar /tmp/lofarhome
else
echo "[INFO] Moving to /home/lofar and setting as home"
cd /home/lofar
export HOME=/home/lofar
echo ""
echo "[INFO] Executing entrypoint..."
if [ "x$GUI" == "xTrue" ]; then
if [ "x$BASE_PORT" == "x" ]; then
echo "[INFO] No task base port set, will set noVNC port 8590 and VNC port 5900 with desktop id \"0\""
else
echo "[INFO] Task base port set, will set noVNC port $BASE_PORT and noVNC port $(($BASE_PORT+1)) with desktop id \"$(($BASE_PORT-5900+1))\""
fi
fi
#---------------------
# Setup home
#---------------------
echo "[INFO] Setting new prompt @$CONTAINER_NAME container"
echo 'export PS1="${debian_chroot:+($debian_chroot)}\u@$CONTAINER_NAME@\h:\w\$ "' >> /tmp/lofarhome/.bashrc
if [ -f "/home/lofar/.initialized" ]; then
:
else
echo "[INFO] Setting up home"
mkdir -p /home/lofar
# Set entrypoint command
if [ "x$@" == "x" ]; then
COMMAND="/bin/bash"
else
COMMAND="$@"
fi
# Copy over vanilla home contents
for x in /lofar_home_vanilla/* /lofar_home_vanilla/.[!.]* /lofar_home_vanilla/..?*; do
if [ -e "$x" ]; then cp -a "$x" /home/lofar/; fi
done
# Mark as initialized
touch /home/lofar/.initialized
fi
#---------------------
# Save env
#---------------------
echo "[INFO] Dumping env"
# Save env vars for later usage (e.g. ssh)
env | \
while read env_var; do
if [[ $env_var == HOME\=* ]]; then
: # Skip HOME var
elif [[ $env_var == PWD\=* ]]; then
: # Skip PWD var
else
echo "export $env_var" >> /tmp/env.sh
fi
done
#---------------------
# VNC Password
#---------------------
if [ "x$GUI" == "xTrue" ]; then
if [ "x$AUTH_PASS" != "x" ]; then
echo "[INFO] Setting up VNC password..."
mkdir -p /home/lofar/.vnc
/opt/tigervnc/usr/bin/vncpasswd -f <<< $AUTH_PASS > /home/lofar/.vnc/passwd
chmod 600 /home/lofar/.vnc/passwd
export VNC_AUTH=True
else
echo "[INFO] Not setting up any VNC password"
fi
fi
echo "[INFO] Creating /tmp/lofarhome to be used as lofar home"
mkdir /tmp/lofarhome
echo "[INFO] Initializing /tmp/lofarhome with configuration files"
cp -aT /lofar_home_vanilla /tmp/lofarhome
echo "[INFO] Moving to /home/lofar and setting as home"
cd /home/lofar
export HOME=/home/lofar
echo "[INFO] Setting new prompt @$CONTAINER_NAME container"
echo 'export PS1="${debian_chroot:+($debian_chroot)}\u@$CONTAINER_NAME@\h:\w\$ "' >> /tmp/lofarhome/.bashrc
echo "[INFO] Sourcing env in /opt/lofarsoft/lofarinit.sh..."
source /opt/lofarsoft/lofarinit.sh
# Set entrypoint command
if [ "x$@" == "x" ]; then
if [ "x$GUI" == "xTrue" ]; then
COMMAND="supervisord -c /etc/supervisor/supervisord.conf"
else
COMMAND="/bin/bash"
fi
else
COMMAND="$@"
fi
# Start!
echo -n "[INFO] Will execute entrypoint command: "
echo $COMMAND
echo ""
echo "=============================================================="
echo ""
echo " Welcome to the LOFAR-IT $CONTAINER_NAME container!"
echo ""
echo "=============================================================="
echo ""
echo "You are now in /home/lofar with write access as user \"$(whoami)\"."
echo ""
echo "Remember that contents inside this container, unless stored"
echo "on a persistent volume mounted from you host machine, will"
echo "be wiped out when exiting the container."
echo ""
exec $COMMAND
# Start!
echo -n "[INFO] Will execute entrypoint command: "
echo $COMMAND
echo ""
echo "=============================================================="
echo ""
echo " Welcome to the LOFAR-IT $CONTAINER_NAME container!"
echo ""
echo "=============================================================="
echo ""
echo "You are now in /home/lofar with write access as user \"$(whoami)\"."
echo ""
echo "Remember that contents inside this container, unless stored"
echo "on a persistent volume mounted from you host machine, will"
echo "be wiped out when exiting the container."
echo ""
exec $COMMAND
fi
[app] (name=fbrun)
[Position] (WINCENTER) {0 0}
[Layer] {2}
[end]
session.screen0.tabs.usePixmap: true
session.screen0.tabs.maxOver: false
session.screen0.tabs.intitlebar: true
session.screen0.clientMenu.usePixmap: true
session.screen0.iconbar.usePixmap: true
session.screen0.iconbar.iconTextPadding: 10
session.screen0.iconbar.iconWidth: 128
session.screen0.iconbar.alignment: Relative
session.screen0.iconbar.mode: {static groups} (workspace)
session.screen0.toolbar.visible: true
session.screen0.toolbar.height: 0
session.screen0.toolbar.onhead: 1
session.screen0.toolbar.widthPercent: 100
session.screen0.toolbar.alpha: 255
session.screen0.toolbar.maxOver: false
session.screen0.toolbar.autoHide: false
session.screen0.toolbar.layer: Dock
session.screen0.toolbar.placement: BottomCenter
#session.screen0.toolbar.tools: prevworkspace, workspacename, nextworkspace, clock, prevwindow, nextwindow, iconbar, systemtray
session.screen0.toolbar.tools: iconbar, systemtray
session.screen0.menu.alpha: 255
session.screen0.tab.placement: TopLeft
session.screen0.tab.width: 64
session.screen0.titlebar.left: Stick
session.screen0.titlebar.right: Minimize Maximize Close
session.screen0.window.focus.alpha: 255
session.screen0.window.unfocus.alpha: 255
session.screen0.slit.alpha: 255
session.screen0.slit.maxOver: false
session.screen0.slit.placement: RightBottom
session.screen0.slit.autoHide: false
session.screen0.slit.acceptKdeDockapps: true
session.screen0.slit.onhead: 0
session.screen0.slit.layer: Dock
session.screen0.colPlacementDirection: TopToBottom
session.screen0.tabFocusModel: ClickToTabFocus
session.screen0.autoRaise: true
session.screen0.maxDisableMove: false
session.screen0.edgeSnapThreshold: 10
session.screen0.tooltipDelay: 500
session.screen0.opaqueMove: true
session.screen0.windowPlacement: RowMinOverlapPlacement
session.screen0.focusNewWindows: true
session.screen0.clickRaises: true
session.screen0.maxDisableResize: false
session.screen0.windowMenu: /home/lofar/.fluxbox/windowmenu
session.screen0.allowRemoteActions: false
session.screen0.strftimeFormat: %d %b, %a %02k:%M:%S
session.screen0.focusSameHead: false
session.screen0.workspacewarping: true
session.screen0.fullMaximization: false
session.screen0.defaultDeco: NORMAL
session.screen0.noFocusWhileTypingDelay: 0
session.screen0.menuDelay: 200
session.screen0.workspaceNames: Workspace 1,Workspace 2,Workspace 3,Workspace 4,
session.screen0.rowPlacementDirection: LeftToRight
session.screen0.focusModel: ClickFocus
session.screen0.showwindowposition: false
session.screen0.maxIgnoreIncrement: true
session.screen0.workspaces: 1
session.styleOverlay: /home/lofar/.fluxbox/overlay
session.keyFile: ~/.fluxbox/keys
session.cacheMax: 200
session.tabsAttachArea: Window
session.slitlistFile: /home/lofar/.fluxbox/slitlist
session.forcePseudoTransparency: false
session.tabPadding: 0
session.colorsPerChannel: 4
session.styleFile: /usr/share/fluxbox/styles//ubuntu-light
session.autoRaiseDelay: 250
session.cacheLife: 5
session.appsFile: /home/lofar/.fluxbox/apps
session.ignoreBorder: false
session.configVersion: 13
session.doubleClickInterval: 250
session.menuFile: ~/.fluxbox/menu
# click on the desktop to get menus
OnDesktop Mouse1 :HideMenus
OnDesktop Mouse2 :WorkspaceMenu
OnDesktop Mouse3 :RootMenu
# scroll on the desktop to change workspaces
OnDesktop Mouse4 :PrevWorkspace
OnDesktop Mouse5 :NextWorkspace
# scroll on the toolbar to change current window
OnToolbar Mouse4 :PrevWindow {static groups} (iconhidden=no)
OnToolbar Mouse5 :NextWindow {static groups} (iconhidden=no)
# alt + left/right click to move/resize a window
OnWindow Mod1 Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}
OnWindowBorder Move1 :StartMoving
OnWindow Mod1 Mouse3 :MacroCmd {Raise} {Focus} {StartResizing NearestCorner}
OnLeftGrip Move1 :StartResizing bottomleft
OnRightGrip Move1 :StartResizing bottomright
# alt + middle click to lower the window
OnWindow Mod1 Mouse2 :Lower
# control-click a window's titlebar and drag to attach windows
OnTitlebar Control Mouse1 :StartTabbing
# double click on the titlebar to shade
OnTitlebar Double Mouse1 :Shade
# left click on the titlebar to move the window
OnTitlebar Mouse1 :MacroCmd {Raise} {Focus} {ActivateTab}
OnTitlebar Move1 :StartMoving
# middle click on the titlebar to lower
OnTitlebar Mouse2 :Lower
# right click on the titlebar for a menu of options
OnTitlebar Mouse3 :WindowMenu
# alt-tab
Mod1 Tab :NextWindow {groups} (workspace=[current])
Mod1 Shift Tab :PrevWindow {groups} (workspace=[current])
# cycle through tabs in the current window
Mod4 Tab :NextTab
Mod4 Shift Tab :PrevTab
# go to a specific tab in the current window
Mod4 1 :Tab 1
Mod4 2 :Tab 2
Mod4 3 :Tab 3
Mod4 4 :Tab 4
Mod4 5 :Tab 5
Mod4 6 :Tab 6
Mod4 7 :Tab 7
Mod4 8 :Tab 8
Mod4 9 :Tab 9
# open a terminal
Mod1 F1 :Exec x-terminal-emulator
# open a dialog to run programs
Mod1 F2 :Exec fbrun
# volume settings, using common keycodes
# if these don't work, use xev to find out your real keycodes
176 :Exec amixer sset Master,0 1+
174 :Exec amixer sset Master,0 1-
160 :Exec amixer sset Master,0 toggle
# current window commands
Mod1 F4 :Close
Mod1 F5 :Kill
Mod1 F9 :Minimize
Mod1 F10 :Maximize
Mod1 F11 :Fullscreen
# open the window menu
Mod1 space :WindowMenu
# exit fluxbox
Control Mod1 Delete :Exit
# change to previous/next workspace
Control Mod1 Left :PrevWorkspace
Control Mod1 Right :NextWorkspace
# send the current window to previous/next workspace
Mod4 Left :SendToPrevWorkspace
Mod4 Right :SendToNextWorkspace
# send the current window and follow it to previous/next workspace
Control Mod4 Left :TakeToPrevWorkspace
Control Mod4 Right :TakeToNextWorkspace
# change to a specific workspace
Control F1 :Workspace 1
Control F2 :Workspace 2
Control F3 :Workspace 3
Control F4 :Workspace 4
Control F5 :Workspace 5
Control F6 :Workspace 6
Control F7 :Workspace 7
Control F8 :Workspace 8
Control F9 :Workspace 9
Control F10 :Workspace 10
Control F11 :Workspace 11
Control F12 :Workspace 12
# send the current window to a specific workspace
Mod4 F1 :SendToWorkspace 1
Mod4 F2 :SendToWorkspace 2
Mod4 F3 :SendToWorkspace 3
Mod4 F4 :SendToWorkspace 4
Mod4 F5 :SendToWorkspace 5
Mod4 F6 :SendToWorkspace 6
Mod4 F7 :SendToWorkspace 7
Mod4 F8 :SendToWorkspace 8
Mod4 F9 :SendToWorkspace 9
Mod4 F10 :SendToWorkspace 10
Mod4 F11 :SendToWorkspace 11
Mod4 F12 :SendToWorkspace 12
# send the current window and change to a specific workspace
Control Mod4 F1 :TakeToWorkspace 1
Control Mod4 F2 :TakeToWorkspace 2
Control Mod4 F3 :TakeToWorkspace 3
Control Mod4 F4 :TakeToWorkspace 4
Control Mod4 F5 :TakeToWorkspace 5
Control Mod4 F6 :TakeToWorkspace 6
Control Mod4 F7 :TakeToWorkspace 7
Control Mod4 F8 :TakeToWorkspace 8
Control Mod4 F9 :TakeToWorkspace 9
Control Mod4 F10 :TakeToWorkspace 10
Control Mod4 F11 :TakeToWorkspace 11
Control Mod4 F12 :TakeToWorkspace 12
$full $full|/usr/share/images/fluxbox/ubuntu-light.png|style|:0.0
[begin] (fluxbox)
[include] (/etc/X11/fluxbox/fluxbox-menu)
[end]
! The following line will prevent styles from setting the background.
! background: none
background: aspect
background.pixmap: /usr/share/images/fluxbox/background.jpg
[begin]
[shade]
[stick]
[maximize]
[iconify]
[raise]
[lower]
[settitledialog]
[sendto]
[layer]
[alpha]
[extramenus]
[separator]
[close]
[end]
<html>
<head>
<script type="text/javascript">
function redirecter(){
window.location = "./vnc.html?autoconnect=true&resize=remote"
}
</script>
</head>
<body onLoad="redirecter()">
Access VNC: click <a href="./vnc.html?autoconnect=true&resize=remote">here</a>.
</body>
</html>
\ No newline at end of file
#!/bin/bash
# Exec TigerVNC server
if [ "x$BASE_PORT" == "x" ]; then
/usr/lib/noVNC/utils/launch.sh --listen 8590
echo "Running noVNC on port 8590"
else
/usr/lib/noVNC/utils/launch.sh --listen $BASE_PORT --vnc localhost:$(($BASE_PORT+1))
echo "Running noVNC on port $BASE_PORT and connecting to VNC on port $(($BASE_PORT+1))"
fi
#!/bin/bash
# Exec TigerVNC server
if [ "x$BASE_PORT" == "x" ]; then
DESKTOP_NUMBER=0
else
DESKTOP_NUMBER=$(($BASE_PORT-5900+1))
fi
if [ "x$VNC_AUTH" == "xTrue" ]; then
/opt/tigervnc/usr/bin/vncserver :$DESKTOP_NUMBER -SecurityTypes vncauth,tlsvnc -xstartup /opt/tigervnc/xstartup
else
/opt/tigervnc/usr/bin/vncserver :$DESKTOP_NUMBER -SecurityTypes None -xstartup /opt/tigervnc/xstartup
fi
# Check it is running. If it is not, exit
while true
do
PSOUT=$(ps -ef | grep /opt/tigervnc/usr/bin/Xvnc | grep SecurityTypes)
if [[ "x$PSOUT" == "x" ]] ; then
exit 1
fi
# Sleep other 10 secs before re-checking
sleep 10
done
; supervisor config file (modified for our own purpose)
[unix_http_server]
file=/home/lofar/.supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/home/lofar/.logs/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/home/lofar/.logs/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/home/lofar/.logs ; ('AUTO' child log dir, default $TEMP)
nodaemon=true ; Mandatory to run Supervisor in foreground and avoid Docker to exit!
; The below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///home/lofar/.supervisor.sock ; use a unix:// URL for a unix socket
; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[include]
files = /etc/supervisor/conf.d/*.conf
;=======================================
; noVNC service
;=======================================
[program:novnc]
; General
directory = /usr/lib/noVNC/
command = /etc/supervisor/conf.d/run_novnc.sh
numprocs = 1
autostart = true
autorestart = true
startsecs = 10
stopwaitsecs = 30
process_name = novnc
; Standard out / error
stdout_logfile = /home/lofar/.logs/%(program_name)s.log
stdout_logfile_maxbytes = 5MB
stdout_logfile_backups = 10
stderr_logfile = /home/lofar/.logs/%(program_name)s.log
stderr_logfile_maxbytes = 5MB
stderr_logfile_backups = 10
;=======================================
; VNC service
;=======================================
[program:vnc]
; General
directory = /
command = /etc/supervisor/conf.d/run_vnc.sh
numprocs = 1
autostart = true
autorestart = true
startsecs = 10
stopwaitsecs = 30
process_name = vnc
; Standard out / error
stdout_logfile = /home/lofar/.logs/%(program_name)s.log
stdout_logfile_maxbytes = 5MB
stdout_logfile_backups = 10
stderr_logfile = /home/lofar/.logs/%(program_name)s.log
stderr_logfile_maxbytes = 5MB
stderr_logfile_backups = 10
#!/bin/sh
cd /home/lofar
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
case "$WINDOWMANAGER" in
*gnome*)
if [ -e /etc/SuSE-release ]; then
PATH=$PATH:/opt/gnome/bin
export PATH
fi
;;
esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" /bin/bash &
#twm &
fluxbox &
......@@ -36,10 +36,63 @@ COPY data/input_data /input_data
COPY data/output_data /output_data
RUN chown lofar:lofar /home/lofar && chown -R lofar:lofar /input_data && chown -R lofar:lofar /output_data
# This is required mainly for Singularity
RUN mv /home/lofar /home/vanilla_lofar
RUN ln -s /tmp/lofarhome /home/lofar
RUN rm -rf /tmp/lofarhome
#----------------------
# Minimal Desktop
#----------------------
# Utilities
RUN apt-get install -y telnet unzip wget supervisor build-essential python-dev git-core openjdk-8-jre
# Global Supervisord conf
COPY files/supervisord.conf /etc/supervisor/
# Install xvfb that triggers minimal install of X base packages and xterm
RUN apt-get install xvfb xterm -y
# Install base packages for VNC server and headless desktop (2)
RUN cd /opt && wget https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.8.0.x86_64.tar.gz -O tigervnc-1.8.0.x86_64.tar.gz \
&& tar -zxvf tigervnc-1.8.0.x86_64.tar.gz \
&& mv tigervnc-1.8.0.x86_64 tigervnc
# Supervisord configuration
COPY files/supervisord_vnc.conf /etc/supervisor/conf.d/
COPY files/run_vnc.sh /etc/supervisor/conf.d/
COPY files/run_novnc.sh /etc/supervisor/conf.d/
RUN chmod 755 /etc/supervisor/conf.d/run_vnc.sh
RUN chmod 755 /etc/supervisor/conf.d/run_novnc.sh
# Web VNC (noVNC) v0.6.1.
# NOTE: this is a custom version from Doro Wu (fcwu.tw@gmail.com).
# TODO: Check differences and maybe move to 0.6.2
COPY files/noVNC.tar.gz /usr/lib/
RUN cd /usr/lib/ && tar -zxvf noVNC.tar.gz
COPY files/index.html /usr/lib/noVNC
RUN apt-get install -y net-tools
# Supervisord configuration
COPY files/supervisord_novnc.conf /etc/supervisor/conf.d/
# X environment setup/startup
RUN apt-get install fluxbox -y
COPY files/xstartup /opt/tigervnc/
RUN chmod 755 /opt/tigervnc/xstartup
# Prepare for logs
RUN mkdir /home/lofar/.logs && chown lofar:lofar /home/lofar/.logs
# Add fluxbox customisations
COPY files/dot_fluxbox /home/lofar/.fluxbox
RUN chown -R lofar:lofar /home/lofar/.fluxbox
COPY files/background.jpg /usr/share/images/fluxbox/background.jpg
# Rename lofar home folder as a "vanilla" home folder
RUN mv /home/lofar /lofar_home_vanilla
# Give write access to anyone to the home folder so the entrypoint will be able
# to copy over the /home/matauser_vanilla into /home/lofar (for Singularity)
RUN chmod 777 /home
#----------------------
......
#!/bin/bash
# Exit on any error. More complex thing could be done in future
# Exit on any error. More complex stuff could be done in future
# (see https://stackoverflow.com/questions/4381618/exit-a-script-on-error)
set -e
echo ""
echo "[INFO] Executing entrypoint..."
#echo "[INFO] Sourcing env in /opt/lofarsoft/lofarinit.sh..."
#source /opt/lofarsoft/lofarinit.sh
if [ "x$SAFE_MODE" == "xTrue" ]; then
echo "[INFO] Creating /tmp/lofarhome to be used as lofar home"
mkdir /tmp/lofarhome
echo ""
echo "[INFO] Not executing entrypoint as we are in safe mode, just opening a Bash shell."
exec /bin/bash
echo "[INFO] Initialising /tmp/lofarhome with configuration files"
cp -aT /home/vanilla_lofar /tmp/lofarhome
else
echo "[INFO] Moving to /home/lofar and setting as home"
cd /home/lofar
export HOME=/home/lofar
echo ""
echo "[INFO] Executing entrypoint..."
if [ "x$GUI" == "xTrue" ]; then
if [ "x$BASE_PORT" == "x" ]; then
echo "[INFO] No task base port set, will set noVNC port 8590 and VNC port 5900 with desktop id \"0\""
else
echo "[INFO] Task base port set, will set noVNC port $BASE_PORT and noVNC port $(($BASE_PORT+1)) with desktop id \"$(($BASE_PORT-5900+1))\""
fi
fi
#---------------------
# Setup home
#---------------------
echo "[INFO] Setting new prompt @$CONTAINER_NAME container"
echo 'export PS1="${debian_chroot:+($debian_chroot)}\u@$CONTAINER_NAME@\h:\w\$ "' >> /tmp/lofarhome/.bashrc
if [ -f "/home/lofar/.initialized" ]; then
:
else
echo "[INFO] Setting up home"
mkdir -p /home/lofar
# Set entrypoint command
if [ "x$@" == "x" ]; then
COMMAND="/bin/bash"
else
COMMAND="$@"
fi
# Copy over vanilla home contents
for x in /lofar_home_vanilla/* /lofar_home_vanilla/.[!.]* /lofar_home_vanilla/..?*; do
if [ -e "$x" ]; then cp -a "$x" /home/lofar/; fi
done
# Mark as initialized
touch /home/lofar/.initialized
fi
#---------------------
# Save env
#---------------------
echo "[INFO] Dumping env"
# Save env vars for later usage (e.g. ssh)
env | \
while read env_var; do
if [[ $env_var == HOME\=* ]]; then
: # Skip HOME var
elif [[ $env_var == PWD\=* ]]; then
: # Skip PWD var
else
echo "export $env_var" >> /tmp/env.sh
fi
done
#---------------------
# VNC Password
#---------------------
if [ "x$GUI" == "xTrue" ]; then
if [ "x$AUTH_PASS" != "x" ]; then
echo "[INFO] Setting up VNC password..."
mkdir -p /home/lofar/.vnc
/opt/tigervnc/usr/bin/vncpasswd -f <<< $AUTH_PASS > /home/lofar/.vnc/passwd
chmod 600 /home/lofar/.vnc/passwd
export VNC_AUTH=True
else
echo "[INFO] Not setting up any VNC password"
fi
fi
echo "[INFO] Creating /tmp/lofarhome to be used as lofar home"
mkdir /tmp/lofarhome
echo "[INFO] Initializing /tmp/lofarhome with configuration files"
cp -aT /lofar_home_vanilla /tmp/lofarhome
echo "[INFO] Moving to /home/lofar and setting as home"
cd /home/lofar
export HOME=/home/lofar
echo "[INFO] Setting new prompt @$CONTAINER_NAME container"
echo 'export PS1="${debian_chroot:+($debian_chroot)}\u@$CONTAINER_NAME@\h:\w\$ "' >> /tmp/lofarhome/.bashrc
# Set entrypoint command
if [ "x$@" == "x" ]; then
if [ "x$GUI" == "xTrue" ]; then
COMMAND="supervisord -c /etc/supervisor/supervisord.conf"
else
COMMAND="/bin/bash"
fi
else
COMMAND="$@"
fi
# Start!
echo -n "[INFO] Will execute entrypoint command: "
echo $COMMAND
echo ""
echo "=============================================================="
echo ""
echo " Welcome to the LOFAR-IT $CONTAINER_NAME container!"
echo ""
echo "=============================================================="
echo ""
echo "You are now in /home/lofar with write access as user \"$(whoami)\"."
echo ""
echo "Remember that contents inside this container, unless stored"
echo "on a persistent volume mounted from you host machine, will"
echo "be wiped out when exiting the container."
echo ""
exec $COMMAND
# Start!
echo -n "[INFO] Will execute entrypoint command: "
echo $COMMAND
echo ""
echo "=============================================================="
echo ""
echo " Welcome to the LOFAR-IT $CONTAINER_NAME container!"
echo ""
echo "=============================================================="
echo ""
echo "You are now in /home/lofar with write access as user \"$(whoami)\"."
echo ""
echo "Remember that contents inside this container, unless stored"
echo "on a persistent volume mounted from you host machine, will"
echo "be wiped out when exiting the container."
echo ""
exec $COMMAND
fi