From 99f049a16550e07e4adc0b6f6d39711fa9bbf1be Mon Sep 17 00:00:00 2001 From: signalprime Date: Tue, 7 Jan 2020 21:44:07 +0000 Subject: [PATCH] docker configuration and instructions - CPU edition --- docker/cpu/Dockerfile | 43 ++++++++++++++++++++++ docker/cpu/README.md | 23 ++++++++++++ docker/cpu/conf.d/chromium.conf | 3 ++ docker/cpu/conf.d/fluxbox.conf | 3 ++ docker/cpu/conf.d/jupyter.conf.not_working | 3 ++ docker/cpu/conf.d/websockify.conf | 3 ++ docker/cpu/conf.d/x11vnc.conf | 3 ++ docker/cpu/conf.d/xterm.conf | 3 ++ docker/cpu/conf.d/xvfb.conf | 3 ++ docker/cpu/docker-compose.yml | 22 +++++++++++ docker/cpu/entrypoint.sh | 22 +++++++++++ docker/cpu/supervisord.conf | 5 +++ 12 files changed, 136 insertions(+) create mode 100644 docker/cpu/Dockerfile create mode 100644 docker/cpu/README.md create mode 100644 docker/cpu/conf.d/chromium.conf create mode 100644 docker/cpu/conf.d/fluxbox.conf create mode 100644 docker/cpu/conf.d/jupyter.conf.not_working create mode 100644 docker/cpu/conf.d/websockify.conf create mode 100644 docker/cpu/conf.d/x11vnc.conf create mode 100644 docker/cpu/conf.d/xterm.conf create mode 100644 docker/cpu/conf.d/xvfb.conf create mode 100644 docker/cpu/docker-compose.yml create mode 100755 docker/cpu/entrypoint.sh create mode 100644 docker/cpu/supervisord.conf diff --git a/docker/cpu/Dockerfile b/docker/cpu/Dockerfile new file mode 100644 index 00000000..b2e52d7a --- /dev/null +++ b/docker/cpu/Dockerfile @@ -0,0 +1,43 @@ +FROM debian:stretch + +# Install git, supervisor, VNC, & X11 packages +RUN set -ex; \ + apt-get update; \ + apt-get install -y \ + bash \ + fluxbox \ + git \ + net-tools \ + novnc \ + supervisor \ + x11vnc \ + xterm \ + xvfb \ + vim \ + python3 \ + python3-tk \ + python3-pip \ + lsof \ + git \ + libsm6 \ + libxext6 \ + libxrender-dev \ + byobu \ + chromium + +RUN python3 -m pip install tornado tensorflow==1.12.0 opencv-python==3.4.4.19 gym==0.10.11 backtrader==1.9.74.123 pyzmq==17.1.2 matplotlib==2.0.2 pillow numpy==1.16.4 scipy==1.3.0 pandas==0.23.4 ipython==7.2.0 psutil==5.4.8 logbook==1.4.1 jupyter jupyter_http_over_ws>=0.0.1a3 + +# Setup demo environment variables +ENV HOME=/root \ + DEBIAN_FRONTEND=noninteractive \ + LANG=en_US.UTF-8 \ + LANGUAGE=en_US.UTF-8 \ + LC_ALL=C.UTF-8 \ + DISPLAY=:0.0 \ + DISPLAY_WIDTH=1800 \ + DISPLAY_HEIGHT=900 \ + RUN_XTERM=yes \ + RUN_FLUXBOX=yes +COPY . /app +CMD ["/app/entrypoint.sh"] +EXPOSE 8888 8080 6007 diff --git a/docker/cpu/README.md b/docker/cpu/README.md new file mode 100644 index 00000000..32ff7f69 --- /dev/null +++ b/docker/cpu/README.md @@ -0,0 +1,23 @@ +# btgym docker for CPU only + +## To Build +- sudo docker image build -t btgym . + +## To Run +- docker container run -p 8080:8080 -p 6006:6006 -p 8888:8888 btgym + +### To link local directory +- add "-v /local_dir:/container_dir" + +### To use your own copy of btgym +- comment out the following line in entrypoint.sh +exec git clone https://github.com/Kismuz/btgym.git /workspace & + +## Notes +The container starts with chromium opening the jupyter nootbook authorization, select the file nbserver-#-open.html to access the notbook server. + +##### Original credits to: +- https://github.com/theasp/docker + +##### Which was based on: +- https://github.com/psharkey/docker/tree/master/novnc diff --git a/docker/cpu/conf.d/chromium.conf b/docker/cpu/conf.d/chromium.conf new file mode 100644 index 00000000..776df8f0 --- /dev/null +++ b/docker/cpu/conf.d/chromium.conf @@ -0,0 +1,3 @@ +[program:chromium] +command=chromium --no-sandbox file:///root/.local/share/jupyter/runtime/ > /dev/null +autorestart=true diff --git a/docker/cpu/conf.d/fluxbox.conf b/docker/cpu/conf.d/fluxbox.conf new file mode 100644 index 00000000..96793ad6 --- /dev/null +++ b/docker/cpu/conf.d/fluxbox.conf @@ -0,0 +1,3 @@ +[program:fluxbox] +command=fluxbox +autorestart=true diff --git a/docker/cpu/conf.d/jupyter.conf.not_working b/docker/cpu/conf.d/jupyter.conf.not_working new file mode 100644 index 00000000..65f1c6a0 --- /dev/null +++ b/docker/cpu/conf.d/jupyter.conf.not_working @@ -0,0 +1,3 @@ +[program:jupyter] +command=jupyter notebook --notebook-dir=/workspace/ --ip 0.0.0.0 --allow-root --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0 +autorestart=true diff --git a/docker/cpu/conf.d/websockify.conf b/docker/cpu/conf.d/websockify.conf new file mode 100644 index 00000000..d15418cf --- /dev/null +++ b/docker/cpu/conf.d/websockify.conf @@ -0,0 +1,3 @@ +[program:websockify] +command=websockify --web /usr/share/novnc 8080 localhost:5900 +autorestart=true diff --git a/docker/cpu/conf.d/x11vnc.conf b/docker/cpu/conf.d/x11vnc.conf new file mode 100644 index 00000000..2fff49af --- /dev/null +++ b/docker/cpu/conf.d/x11vnc.conf @@ -0,0 +1,3 @@ +[program:x11vnc] +command=x11vnc -forever -shared +autorestart=true diff --git a/docker/cpu/conf.d/xterm.conf b/docker/cpu/conf.d/xterm.conf new file mode 100644 index 00000000..da1af445 --- /dev/null +++ b/docker/cpu/conf.d/xterm.conf @@ -0,0 +1,3 @@ +[program:xterm] +command=xterm +autorestart=true diff --git a/docker/cpu/conf.d/xvfb.conf b/docker/cpu/conf.d/xvfb.conf new file mode 100644 index 00000000..29949d8e --- /dev/null +++ b/docker/cpu/conf.d/xvfb.conf @@ -0,0 +1,3 @@ +[program:xvfb] +command=Xvfb :0 -screen 0 "%(ENV_DISPLAY_WIDTH)s"x"%(ENV_DISPLAY_HEIGHT)s"x24 -listen tcp -ac +autorestart=true diff --git a/docker/cpu/docker-compose.yml b/docker/cpu/docker-compose.yml new file mode 100644 index 00000000..c668462b --- /dev/null +++ b/docker/cpu/docker-compose.yml @@ -0,0 +1,22 @@ +version: '2' +services: + ide: + image: psharkey/intellij:latest + environment: + - DISPLAY=novnc:0.0 + depends_on: + - novnc + networks: + - x11 + novnc: + image: theasp/novnc:latest + environment: + # Adjust to your screen size + - DISPLAY_WIDTH=1600 + - DISPLAY_HEIGHT=968 + ports: + - "8080:8080" + networks: + - x11 +networks: + x11: diff --git a/docker/cpu/entrypoint.sh b/docker/cpu/entrypoint.sh new file mode 100755 index 00000000..cd57bb49 --- /dev/null +++ b/docker/cpu/entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -ex + +RUN_FLUXBOX=${RUN_FLUXBOX:-yes} +RUN_XTERM=${RUN_XTERM:-yes} + +case $RUN_FLUXBOX in + false|no|n|0) + rm -f /app/conf.d/fluxbox.conf + ;; +esac + +case $RUN_XTERM in + false|no|n|0) + rm -f /app/conf.d/xterm.conf + ;; +esac +exec git clone https://github.com/Kismuz/btgym.git /workspace & +exec jupyter serverextension enable --py jupyter_http_over_ws & +exec tensorboard --logdir=/workspace/btgym/logdir & +exec jupyter notebook --notebook-dir=/workspace/ --ip 0.0.0.0 --allow-root --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0 & +exec supervisord -c /app/supervisord.conf diff --git a/docker/cpu/supervisord.conf b/docker/cpu/supervisord.conf new file mode 100644 index 00000000..3dd2ac76 --- /dev/null +++ b/docker/cpu/supervisord.conf @@ -0,0 +1,5 @@ +[supervisord] +nodaemon=true + +[include] +files = /app/conf.d/*.conf