forked from ml-tooling/ml-workspace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
944 lines (842 loc) · 35.8 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
FROM ubuntu:22.04
USER root
### BASICS ###
# Technical Environment Variables
ENV \
SHELL="/bin/bash" \
HOME="/root" \
# Nobteook server user: https://github.com/jupyter/docker-stacks/blob/master/base-notebook/Dockerfile#L33
NB_USER="root" \
USER_GID=0 \
XDG_CACHE_HOME="/root/.cache/" \
XDG_RUNTIME_DIR="/tmp" \
DISPLAY=":1" \
TERM="xterm" \
DEBIAN_FRONTEND="noninteractive" \
RESOURCES_PATH="/resources" \
SSL_RESOURCES_PATH="/resources/ssl" \
WORKSPACE_HOME="/workspace"
WORKDIR $HOME
# Make folders
RUN \
mkdir $RESOURCES_PATH && chmod a+rwx $RESOURCES_PATH && \
mkdir $WORKSPACE_HOME && chmod a+rwx $WORKSPACE_HOME && \
mkdir $SSL_RESOURCES_PATH && chmod a+rwx $SSL_RESOURCES_PATH
# Layer cleanup script
COPY resources/scripts/clean-layer.sh /usr/bin/clean-layer.sh
COPY resources/scripts/fix-permissions.sh /usr/bin/fix-permissions.sh
# Make clean-layer and fix-permissions executable
RUN \
chmod a+rwx /usr/bin/clean-layer.sh && \
chmod a+rwx /usr/bin/fix-permissions.sh
# Generate and Set locals
# https://stackoverflow.com/questions/28405902/how-to-set-the-locale-inside-a-debian-ubuntu-docker-container#38553499
RUN \
apt-get update && \
apt-get install -y locales && \
# install locales-all?
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 && \
# Cleanup
clean-layer.sh
ENV LC_ALL="en_US.UTF-8" \
LANG="en_US.UTF-8" \
LANGUAGE="en_US:en"
RUN \
apt-get update && \
apt-get install -y software-properties-common && \
#apt-get install -y add-apt-repository && \
add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse" && \
# Cleanup
clean-layer.sh
# Install basics
RUN \
apt-get update --fix-missing && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
# This is necessary for apt to access HTTPS sources:
apt-transport-https \
gnupg-agent \
gpg-agent \
gnupg2 \
ca-certificates \
build-essential \
pkg-config \
software-properties-common \
lsof \
net-tools \
libcurl4 \
curl \
wget \
cron \
openssl \
iproute2 \
psmisc \
tmux \
dpkg-sig \
uuid-dev \
csh \
xclip \
clinfo \
time \
libssl-dev \
libgdbm-dev \
libncurses5-dev \
libncursesw5-dev \
# required by pyenv
libreadline-dev \
libedit-dev \
xz-utils \
gawk \
# Simplified Wrapper and Interface Generator (5.8MB) - required by lots of py-libs
swig \
# Graphviz (graph visualization software) (4MB)
graphviz libgraphviz-dev \
# Terminal multiplexer
screen \
# Editor
nano \
# Find files
locate \
# Dev Tools
sqlite3 \
# XML Utils
xmlstarlet \
# GNU parallel
parallel \
# image processing library (6MB), required for tesseract
libleptonica-dev \
# GEOS library (3MB)
libgeos-dev \
# style sheet preprocessor
less \
# Print dir tree
tree \
# Bash autocompletion functionality
bash-completion \
# ping support
iputils-ping \
# Map remote ports to localhost
socat \
# Json Processor
jq \
rsync \
# sqlite3 driver - required for pyenv
libsqlite3-dev \
# VCS:
git \
subversion \
jed \
# odbc drivers
unixodbc unixodbc-dev \
# Image support
libtiff-dev \
libjpeg-dev \
libpng-dev \
libglib2.0-0 \
libxext6 \
libsm6 \
libxext-dev \
libxrender1 \
libzmq3-dev \
# protobuffer support
protobuf-compiler \
libprotobuf-dev \
libprotoc-dev \
autoconf \
automake \
libtool \
cmake \
fonts-liberation \
google-perftools \
# Compression Libs
# also install rar/unrar? but both are propriatory or unar (40MB)
zip \
gzip \
unzip \
bzip2 \
lzop \
# deprecates bsdtar (https://ubuntu.pkgs.org/20.04/ubuntu-universe-i386/libarchive-tools_3.4.0-2ubuntu1_i386.deb.html)
libarchive-tools \
zlib1g-dev \
# unpack (almost) everything with one command
unp \
libbz2-dev \
liblzma-dev \
zlib1g-dev && \
# Fix all execution permissions
chmod -R a+rwx /usr/local/bin/ && \
# configure dynamic linker run-time bindings
ldconfig && \
# Fix permissions
fix-permissions.sh $HOME && \
# Cleanup
clean-layer.sh
# Add tini
RUN wget --no-verbose https://github.com/krallin/tini/releases/download/v0.19.0/tini -O /tini && \
chmod +x /tini
# prepare ssh for inter-container communication for remote python kernel
RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
openssh-client \
openssh-server \
# SSLH for SSH + HTTP(s) Multiplexing
sslh \
# SSH Tooling
autossh \
mussh && \
chmod go-w $HOME && \
mkdir -p $HOME/.ssh/ && \
# create empty config file if not exists
touch $HOME/.ssh/config && \
chown -R $NB_USER:users $HOME/.ssh && \
chmod 700 $HOME/.ssh && \
printenv >> $HOME/.ssh/environment && \
chmod -R a+rwx /usr/local/bin/ && \
# Fix permissions
fix-permissions.sh $HOME && \
# Cleanup
clean-layer.sh
RUN \
OPEN_RESTY_VERSION="1.25.3.1" && \
mkdir $RESOURCES_PATH"/openresty" && \
cd $RESOURCES_PATH"/openresty" && \
apt-get update && \
apt-get purge -y nginx nginx-common && \
# libpcre required, otherwise you get a 'the HTTP rewrite module requires the PCRE library' error
# Install apache2-utils to generate user:password file for nginx.
apt-get install -y libpcre3 libpcre3-dev apache2-utils && \
wget --no-verbose https://openresty.org/download/openresty-$OPEN_RESTY_VERSION.tar.gz -O ./openresty.tar.gz && \
tar xfz ./openresty.tar.gz && \
rm ./openresty.tar.gz && \
cd ./openresty-$OPEN_RESTY_VERSION/ && \
# Surpress output - if there is a problem remove > /dev/null
./configure --with-http_stub_status_module --with-http_sub_module > /dev/null && \
make -j2 > /dev/null && \
make install > /dev/null && \
# create log dir and file - otherwise openresty will throw an error
mkdir -p /var/log/nginx/ && \
touch /var/log/nginx/upstream.log && \
cd $RESOURCES_PATH && \
rm -r $RESOURCES_PATH"/openresty" && \
# Fix permissions
chmod -R a+rwx $RESOURCES_PATH && \
# Cleanup
clean-layer.sh
ENV PATH=/usr/local/openresty/nginx/sbin:$PATH
COPY resources/nginx/lua-extensions /etc/nginx/nginx_plugins
### END BASICS ###
### RUNTIMES ###
# Install Miniconda: https://repo.continuum.io/miniconda/
ENV \
# TODO: CONDA_DIR is deprecated and should be removed in the future
CONDA_DIR=/opt/conda \
CONDA_ROOT=/opt/conda \
PYTHON_VERSION="3.10" \
CONDA_PYTHON_DIR=/opt/conda/lib/python3.10 \
MINICONDA_VERSION=24.4.0-0 \
MINICONDA_MD5=fdaa5afdea8c07b6f2203b8f95abe0e4e8c4d3fd3c10d19fe590311446591ffa \
CONDA_VERSION=24.4.0-0
RUN wget --no-verbose https://repo.anaconda.com/miniconda/Miniconda3-py310_${CONDA_VERSION}-Linux-x86_64.sh -O ~/miniconda.sh && \
#echo "${MINICONDA_MD5} *miniconda.sh" | md5sum -c - && \
/bin/bash ~/miniconda.sh -b -p $CONDA_ROOT && \
export PATH=$CONDA_ROOT/bin:$PATH && \
rm ~/miniconda.sh && \
# Configure conda
# TODO: Add conde-forge as main channel -> remove if testted
# TODO, use condarc file
$CONDA_ROOT/bin/conda config --system --add channels conda-forge && \
$CONDA_ROOT/bin/conda config --system --set auto_update_conda False && \
$CONDA_ROOT/bin/conda config --system --set show_channel_urls True && \
$CONDA_ROOT/bin/conda config --system --set channel_priority strict && \
# Deactivate pip interoperability (currently default), otherwise conda tries to uninstall pip packages
$CONDA_ROOT/bin/conda config --system --set pip_interop_enabled false && \
# Update conda
$CONDA_ROOT/bin/conda update -y -n base -c defaults conda && \
$CONDA_ROOT/bin/conda update -y setuptools && \
$CONDA_ROOT/bin/conda install -y conda-build && \
# Update selected packages - install python 3.8.x
$CONDA_ROOT/bin/conda install -y --update-all python=$PYTHON_VERSION && \
# Link Conda
ln -s $CONDA_ROOT/bin/python /usr/local/bin/python && \
ln -s $CONDA_ROOT/bin/conda /usr/bin/conda && \
# Update
$CONDA_ROOT/bin/conda install -y pip && \
$CONDA_ROOT/bin/pip install --upgrade pip && \
chmod -R a+rwx /usr/local/bin/ && \
# Cleanup - Remove all here since conda is not in path as of now
# find /opt/conda/ -follow -type f -name '*.a' -delete && \
# find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
$CONDA_ROOT/bin/conda clean -y --packages && \
$CONDA_ROOT/bin/conda clean -y -a -f && \
$CONDA_ROOT/bin/conda build purge-all && \
# Fix permissions
fix-permissions.sh $CONDA_ROOT && \
clean-layer.sh
ENV PATH=$CONDA_ROOT/bin:$PATH
# There is nothing added yet to LD_LIBRARY_PATH, so we can overwrite
ENV LD_LIBRARY_PATH=$CONDA_ROOT/lib
# Install pyenv to allow dynamic creation of python versions
RUN git clone https://github.com/pyenv/pyenv.git $RESOURCES_PATH/.pyenv && \
# Install pyenv plugins based on pyenv installer
git clone https://github.com/pyenv/pyenv-virtualenv.git $RESOURCES_PATH/.pyenv/plugins/pyenv-virtualenv && \
git clone https://github.com/pyenv/pyenv-doctor.git $RESOURCES_PATH/.pyenv/plugins/pyenv-doctor && \
git clone https://github.com/pyenv/pyenv-update.git $RESOURCES_PATH/.pyenv/plugins/pyenv-update && \
git clone https://github.com/pyenv/pyenv-which-ext.git $RESOURCES_PATH/.pyenv/plugins/pyenv-which-ext && \
apt-get update && \
clean-layer.sh
# Add pyenv to path
ENV PATH=$RESOURCES_PATH/.pyenv/shims:$RESOURCES_PATH/.pyenv/bin:$PATH \
PYENV_ROOT=$RESOURCES_PATH/.pyenv
# Install pipx
RUN pip install pipx && \
# Configure pipx
python -m pipx ensurepath && \
# Cleanup
clean-layer.sh
ENV PATH=$HOME/.local/bin:$PATH
# Install node.js
RUN \
apt-get update && \
# https://nodejs.org/en/about/releases/ use even numbered releases, i.e. LTS versions
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs && \
# As conda is first in path, the commands 'node' and 'npm' reference to the version of conda.
# Replace those versions with the newly installed versions of node
rm -f /opt/conda/bin/node && ln -s /usr/bin/node /opt/conda/bin/node && \
rm -f /opt/conda/bin/npm && ln -s /usr/bin/npm /opt/conda/bin/npm && \
# Fix permissions
chmod a+rwx /usr/bin/node && \
chmod a+rwx /usr/bin/npm && \
# Fix node versions - put into own dir and before conda:
mkdir -p /opt/node/bin && \
ln -s /usr/bin/node /opt/node/bin/node && \
ln -s /usr/bin/npm /opt/node/bin/npm && \
# Update npm
#/usr/bin/npm install -g npm && \
# Install Yarn
/usr/bin/npm install -g yarn && \
# Install typescript
/usr/bin/npm install -g typescript && \
# Install webpack - 32 MB
/usr/bin/npm install -g webpack && \
# Install node-gyp
/usr/bin/npm install -g node-gyp && \
# Update all packages to latest version
#/usr/bin/npm update -g && \
# Cleanup
clean-layer.sh
ENV PATH=/opt/node/bin:$PATH
# Java - removed
### END RUNTIMES ###
### PROCESS TOOLS ###
# Removed XRDP
# Install supervisor for process supervision
RUN \
apt-get update && \
# Create sshd run directory - required for starting process via supervisor
mkdir -p /var/run/sshd && chmod 400 /var/run/sshd && \
# Install rsyslog for syslog logging
apt-get install -y --no-install-recommends rsyslog && \
pipx install supervisor && \
pipx inject supervisor supervisor-stdout && \
# supervisor needs this logging path
mkdir -p /var/log/supervisor/ && \
# Cleanup
clean-layer.sh
### END PROCESS TOOLS ###
### GUI TOOLS ###
# Install xfce4 & gui tools
RUN \
# Use staging channel to get newest xfce4 version (4.16)
add-apt-repository -y ppa:xubuntu-dev/staging && \
apt-get update && \
apt-get install -y --no-install-recommends xfce4 && \
apt-get install -y --no-install-recommends gconf2 && \
apt-get install -y --no-install-recommends xfce4-terminal && \
apt-get install -y --no-install-recommends xfce4-clipman && \
apt-get install -y --no-install-recommends xterm && \
apt-get install -y --no-install-recommends --allow-unauthenticated xfce4-taskmanager && \
# Install dependencies to enable vncserver
apt-get install -y --no-install-recommends xauth xinit dbus-x11 && \
# Install gdebi deb installer
apt-get install -y --no-install-recommends gdebi && \
# Search for files
apt-get install -y --no-install-recommends catfish && \
apt-get install -y --no-install-recommends font-manager && \
# vs support for thunar
apt-get install -y thunar-vcs-plugin && \
# Streaming text editor for large files - klogg is alternative to glogg
apt-get install -y --no-install-recommends libqt5concurrent5 libqt5widgets5 libqt5xml5 && \
wget --no-verbose https://github.com/variar/klogg/releases/download/v20.12/klogg-20.12.0.813-Linux.deb -O $RESOURCES_PATH/klogg.deb && \
dpkg -i $RESOURCES_PATH/klogg.deb && \
rm $RESOURCES_PATH/klogg.deb && \
# Disk Usage Visualizer
apt-get install -y --no-install-recommends baobab && \
# Lightweight text editor
apt-get install -y --no-install-recommends mousepad && \
apt-get install -y --no-install-recommends vim && \
# Process monitoring
apt-get install -y --no-install-recommends htop && \
# Install Archive/Compression Tools: https://wiki.ubuntuusers.de/Archivmanager/
apt-get install -y p7zip p7zip-rar && \
apt-get install -y --no-install-recommends thunar-archive-plugin && \
apt-get install -y xarchiver && \
# DB Utils
apt-get install -y --no-install-recommends sqlitebrowser && \
# Install nautilus and support for sftp mounting
apt-get install -y --no-install-recommends nautilus && \
#apt-get install -y --no-install-recommends nautilus gvfs-backends && \
# Install gigolo - Access remote systems
# apt-get install -y --no-install-recommends gigolo gvfs-bin && \
# xfce systemload panel plugin - needs to be activated
# apt-get install -y --no-install-recommends xfce4-systemload-plugin && \
# Leightweight ftp client that supports sftp, http, ...
apt-get install -y --no-install-recommends gftp && \
apt-get install -y chromium-browser chromium-browser-l10n chromium-codecs-ffmpeg && \
ln -s /usr/bin/chromium-browser /usr/bin/google-chrome && \
# Cleanup
apt-get purge -y pm-utils xscreensaver* && \
# Large package: gnome-user-guide 50MB app-install-data 50MB
apt-get remove -y app-install-data gnome-user-guide && \
clean-layer.sh
# Add the defaults from /lib/x86_64-linux-gnu, otherwise lots of no version errors
# cannot be added above otherwise there are errors in the installation of the gui tools
# Call order: https://unix.stackexchange.com/questions/367600/what-is-the-order-that-linuxs-dynamic-linker-searches-paths-in
ENV LD_LIBRARY_PATH=/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:$CONDA_ROOT/lib
# Install VNC
RUN \
apt-get update && \
cd ${RESOURCES_PATH} && \
# required for tigervnc
apt-get install -y libxfont2 && \
# Tiger VNC
wget -O tigervncserver_1.13.1-1ubuntu1_amd64.deb https://sourceforge.net/projects/tigervnc/files/stable/1.13.1/ubuntu-22.04LTS/amd64/tigervncserver_1.13.1-1ubuntu1_amd64.deb/download && \
dpkg -i tigervncserver_1.13.1-1ubuntu1_amd64.deb && \
rm tigervncserver_1.13.1-1ubuntu1_amd64.deb && \
# required for websockify
apt-get install -y python3-numpy && \
# Install websockify
mkdir -p ./novnc/utils/websockify && \
# Before updating the noVNC version, we need to make sure that our monkey patching scripts still work!!
wget -qO- https://github.com/novnc/noVNC/archive/v1.4.0.tar.gz | tar xz --strip 1 -C ./novnc && \
wget -qO- https://github.com/novnc/websockify/archive/v0.11.0.tar.gz | tar xz --strip 1 -C ./novnc/utils/websockify && \
# create user vnc directory
mkdir -p $HOME/.vnc && \
# Fix permissions
fix-permissions.sh ${RESOURCES_PATH} && \
# Cleanup
clean-layer.sh
# Install Web Tools - Offered via Jupyter Tooling Plugin
## VS Code Server: https://github.com/codercom/code-server
COPY resources/tools/vs-code-server.sh $RESOURCES_PATH/tools/vs-code-server.sh
RUN \
/bin/bash $RESOURCES_PATH/tools/vs-code-server.sh --install && \
# Cleanup
clean-layer.sh
## ungit
COPY resources/tools/ungit.sh $RESOURCES_PATH/tools/ungit.sh
RUN \
/bin/bash $RESOURCES_PATH/tools/ungit.sh --install && \
# Cleanup
clean-layer.sh
## netdata
COPY resources/tools/netdata.sh $RESOURCES_PATH/tools/netdata.sh
RUN \
/bin/bash $RESOURCES_PATH/tools/netdata.sh --install && \
# Cleanup
clean-layer.sh
## Filebrowser
COPY resources/tools/filebrowser.sh $RESOURCES_PATH/tools/filebrowser.sh
RUN \
/bin/bash $RESOURCES_PATH/tools/filebrowser.sh --install && \
# Cleanup
clean-layer.sh
## XRDP
## TODO: make the XRDP work by default in ml-workspace
#COPY resources/tools/xrdp.sh $RESOURCES_PATH/tools/xrdp.h
#RUN \
#/bin/bash $RESOURCES_PATH/tools/xrdp.h --install && \
# Cleanup
#clean-layer.sh
#ARG ARG_WORKSPACE_FLAVOR="full"
ARG ARG_WORKSPACE_FLAVOR="minimal"
ENV WORKSPACE_FLAVOR=$ARG_WORKSPACE_FLAVOR
# Install Visual Studio Code
COPY resources/tools/vs-code-desktop.sh $RESOURCES_PATH/tools/vs-code-desktop.sh
RUN \
# If minimal flavor - do not install
if [ "$WORKSPACE_FLAVOR" = "minimal" ]; then \
exit 0 ; \
fi && \
/bin/bash $RESOURCES_PATH/tools/vs-code-desktop.sh --install && \
# Cleanup
clean-layer.sh
# Install Firefox
COPY resources/tools/firefox.sh $RESOURCES_PATH/tools/firefox.sh
RUN \
# If minimal flavor - do not install
if [ "$WORKSPACE_FLAVOR" = "minimal" ]; then \
exit 0 ; \
fi && \
/bin/bash $RESOURCES_PATH/tools/firefox.sh --install && \
# Cleanup
clean-layer.sh
### END GUI TOOLS ###
### DATA SCIENCE BASICS ###
## Python 3
# Data science libraries requirements
COPY resources/libraries ${RESOURCES_PATH}/libraries
### Install main data science libs
RUN \
# Link Conda - All python are linke to the conda instances
# Linking python 3 crashes conda -> cannot install anyting - remove instead
# ln -s -f $CONDA_ROOT/bin/python /usr/bin/python3 && \
# if removed -> cannot use add-apt-repository
# rm /usr/bin/python3 && \
# rm /usr/bin/python3.5
ln -s -f $CONDA_ROOT/bin/python /usr/bin/python && \
apt-get update && \
# upgrade pip
pip install --upgrade pip && \
# Install some basics - required to run container
conda install -y --update-all \
'python='$PYTHON_VERSION \
'ipython=8.20.*' \
'notebook=6.5.7' \
'jupyterlab=4.0.2' \
# TODO: nbconvert 6.x makes problems with template_path
# 'nbconvert=5.6.*' \
# TODO: temp fix: yarl version 1.5 is required for lots of libraries.
'yarl==1.9.*' && \
# Fix permissions
fix-permissions.sh $CONDA_ROOT && \
# Cleanup
clean-layer.sh
#RUN \
# TODO: update these python package versions and install
# pip install --no-cache-dir --upgrade --upgrade-strategy only-if-needed -r ${RESOURCES_PATH}/libraries/requirements-minimal.txt && \
# Cleanup
# clean-layer.sh
# Fix conda version
RUN \
# Conda installs wrong node version - relink conda node to the actual node
rm -f /opt/conda/bin/node && ln -s /usr/bin/node /opt/conda/bin/node && \
rm -f /opt/conda/bin/npm && ln -s /usr/bin/npm /opt/conda/bin/npm
### END DATA SCIENCE BASICS ###
### JUPYTER ###
COPY \
resources/jupyter/start.sh \
resources/jupyter/start-notebook.sh \
resources/jupyter/start-singleuser.sh \
/usr/local/bin/
# Configure Jupyter / JupyterLab
# Add as jupyter system configuration
COPY resources/jupyter/nbconfig /etc/jupyter/nbconfig
COPY resources/jupyter/jupyter_notebook_config.json /etc/jupyter/
# install jupyter extensions
RUN \
# Create empty notebook configuration
mkdir -p $HOME/.jupyter/nbconfig/ && \
printf "{\"load_extensions\": {}}" > $HOME/.jupyter/nbconfig/notebook.json && \
# Fix permissions? fix-permissions.sh $CONDA_ROOT && \
# Cleanup
clean-layer.sh
# install jupyterlab
RUN \
# without es6-promise some extension builds fail
npm install -g es6-promise && \
# npm install -g @jupyterlab/builder && \
# define alias command for jupyterlab extension installs with log prints to stdout
export NODE_OPTIONS=--openssl-legacy-provider && \
jupyter lab build && \
lab_ext_install='jupyter labextension install -y --debug-log-path=/dev/stdout --log-level=WARN --minimize=False --no-build' && \
# If minimal flavor - do not install jupyterlab extensions
if [ "$WORKSPACE_FLAVOR" = "minimal" ]; then \
# Final build with minimization
jupyter lab build -y --debug-log-path=/dev/stdout --log-level=WARN && \
# Cleanup
jupyter lab clean && \
# the following command throws up a Type Error related to nodejs Path module
# jlpm cache clean && \
rm -rf $CONDA_ROOT/share/jupyter/lab/staging && \
clean-layer.sh && \
exit 0 ; \
fi && \
rm -rf $CONDA_ROOT/share/jupyter/lab/staging && \
clean-layer.sh
# Install Jupyter Tooling Extension
COPY resources/jupyter/extensions $RESOURCES_PATH/jupyter-extensions
RUN \
pip install --no-cache-dir $RESOURCES_PATH/jupyter-extensions/tooling-extension/ && \
# Cleanup
clean-layer.sh
RUN \
pip install -U simplejson && \
# Cleanup
clean-layer.sh
# Install and activate ZSH
COPY resources/tools/oh-my-zsh.sh $RESOURCES_PATH/tools/oh-my-zsh.sh
RUN \
# Install ZSH
/bin/bash $RESOURCES_PATH/tools/oh-my-zsh.sh --install && \
# Make zsh the default shell
# Initialize conda for command line activation
# TODO do not activate for now, opening the bash shell is a bit slow
# conda init bash && \
# conda init zsh && \
chsh -s $(which zsh) $NB_USER && \
# Install sdkman - needs to be executed after zsh
curl -s https://get.sdkman.io | bash && \
# Cleanup
clean-layer.sh
# Install Git LFS
COPY resources/tools/git-lfs.sh $RESOURCES_PATH/tools/git-lfs.sh
RUN \
/bin/bash $RESOURCES_PATH/tools/git-lfs.sh --install && \
# Cleanup
clean-layer.sh
### INCUBATION ZONE ###
RUN \
apt-get update && \
# Required by magenta
# apt-get install -y libasound2-dev && \
# required by rodeo ide (8MB)
# apt-get install -y libgconf2-4 && \
# required for pvporcupine (800kb)
# apt-get install -y portaudio19-dev && \
# Audio drivers for magenta? (3MB)
# apt-get install -y libasound2-dev libjack-dev && \
# libproj-dev required for cartopy (15MB)
# apt-get install -y libproj-dev && \
# mysql server: 150MB
# apt-get install -y mysql-server && \
# If minimal or light flavor -> exit here
if [ "$WORKSPACE_FLAVOR" = "minimal" ] || [ "$WORKSPACE_FLAVOR" = "light" ]; then \
# Cleanup
clean-layer.sh && \
exit 0 ; \
fi && \
# Install fkill-cli program TODO: 30MB, remove?
# npm install --global fkill-cli && \
# Activate pretty-errors
# python -m pretty_errors -u -p && \
# Cleanup
clean-layer.sh
### END INCUBATION ZONE ###
### CONFIGURATION ###
# Copy files into workspace
COPY \
resources/docker-entrypoint.py \
resources/5xx.html \
$RESOURCES_PATH/
# Copy scripts into workspace
COPY resources/scripts $RESOURCES_PATH/scripts
# Create Desktop Icons for Tooling
COPY resources/branding $RESOURCES_PATH/branding
# Configure Home folder (e.g. xfce)
COPY resources/home/ $HOME/
# Copy some configuration files
COPY resources/ssh/ssh_config resources/ssh/sshd_config /etc/ssh/
COPY resources/nginx/nginx.conf /etc/nginx/nginx.conf
COPY resources/config/xrdp.ini /etc/xrdp/xrdp.ini
# Configure supervisor process
COPY resources/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
# Copy all supervisor program definitions into workspace
COPY resources/supervisor/programs/ /etc/supervisor/conf.d/
# Assume yes to all apt commands, to avoid user confusion around stdin.
COPY resources/config/90assumeyes /etc/apt/apt.conf.d/
# Monkey Patching novnc: Styling and added clipboard support. All changed sections are marked with CUSTOM CODE
#COPY resources/novnc/ $RESOURCES_PATH/novnc/
RUN \
## create index.html to forward automatically to `vnc.html`
# Needs to be run after patching
ln -s $RESOURCES_PATH/novnc/vnc.html $RESOURCES_PATH/novnc/index.html
# Basic VNC Settings - no password
ENV \
VNC_PW=vncpassword \
VNC_RESOLUTION=1600x900 \
VNC_COL_DEPTH=24
# Add tensorboard patch - use tensorboard jupyter plugin instead of the actual tensorboard magic
COPY resources/jupyter/tensorboard_notebook_patch.py $CONDA_PYTHON_DIR/site-packages/tensorboard/notebook.py
# Additional jupyter configuration
COPY resources/jupyter/jupyter_notebook_config.py /etc/jupyter/
COPY resources/jupyter/sidebar.jupyterlab-settings $HOME/.jupyter/lab/user-settings/@jupyterlab/application-extension/
COPY resources/jupyter/plugin.jupyterlab-settings $HOME/.jupyter/lab/user-settings/@jupyterlab/extensionmanager-extension/
COPY resources/jupyter/ipython_config.py /etc/ipython/ipython_config.py
# Branding of various components
RUN \
# Jupyter Branding
cp -f $RESOURCES_PATH/branding/logo.png $CONDA_PYTHON_DIR"/site-packages/jupyter_server/static/logo/logo.png" && \
cp -f $RESOURCES_PATH/branding/favicon.ico $CONDA_PYTHON_DIR"/site-packages/jupyter_server/static/favicons/favicon.ico" && \
cp -f $RESOURCES_PATH/branding/favicon.ico $CONDA_PYTHON_DIR"/site-packages/jupyter_server/static/favicons/favicon-notebook.ico" && \
cp -f $RESOURCES_PATH/branding/favicon.ico $CONDA_PYTHON_DIR"/site-packages/jupyter_server/static/favicons/favicon-file.ico" && \
cp -f $RESOURCES_PATH/branding/logo.png $CONDA_PYTHON_DIR"/site-packages/nbclassic/static/base/images/logo.png" && \
cp -f $RESOURCES_PATH/branding/favicon.ico $CONDA_PYTHON_DIR"/site-packages/nbclassic/static/base/images/favicon.ico" && \
cp -f $RESOURCES_PATH/branding/favicon.ico $CONDA_PYTHON_DIR"/site-packages/nbclassic/static/base/images/favicon-file.ico" && \
cp -f $RESOURCES_PATH/branding/favicon.ico $CONDA_PYTHON_DIR"/site-packages/nbclassic/static/base/images/favicon-notebook.ico" && \
#cp -f $RESOURCES_PATH/branding/favicon.ico $CONDA_PYTHON_DIR"/site-packages/notebook/static/base/images/favicon.ico" && \
#cp -f $RESOURCES_PATH/branding/favicon.ico $CONDA_PYTHON_DIR"/site-packages/notebook/static/favicon.ico" && \
# Fielbrowser Branding
mkdir -p $RESOURCES_PATH"/filebrowser/img/icons/" && \
cp -f $RESOURCES_PATH/branding/favicon.ico $RESOURCES_PATH"/filebrowser/img/icons/favicon.ico" && \
cp -f $RESOURCES_PATH/branding/favicon.ico $RESOURCES_PATH"/filebrowser/img/icons/favicon-32x32.png" && \
cp -f $RESOURCES_PATH/branding/favicon.ico $RESOURCES_PATH"/filebrowser/img/icons/favicon-16x16.png" && \
cp -f $RESOURCES_PATH/branding/ml-workspace-logo.svg $RESOURCES_PATH"/filebrowser/img/logo.svg"
# Configure git
RUN \
git config --global core.fileMode false && \
git config --global http.sslVerify false && \
# Use store or credentialstore instead? timout == 365 days validity
git config --global credential.helper 'cache --timeout=31540000'
# Configure netdata
COPY resources/netdata/ /etc/netdata/
COPY resources/netdata/cloud.conf /var/lib/netdata/cloud.d/cloud.conf
# Create Desktop Icons for Tooling
COPY resources/icons $RESOURCES_PATH/icons
RUN \
# ungit:
echo "[Desktop Entry]\nVersion=1.0\nType=Link\nName=Ungit\nComment=Git Client\nCategories=Development;\nIcon=/resources/icons/ungit-icon.png\nURL=http://localhost:8092/tools/ungit" > /usr/share/applications/ungit.desktop && \
chmod +x /usr/share/applications/ungit.desktop && \
# netdata:
echo "[Desktop Entry]\nVersion=1.0\nType=Link\nName=Netdata\nComment=Hardware Monitoring\nCategories=System;Utility;Development;\nIcon=/resources/icons/netdata-icon.png\nURL=http://localhost:8092/tools/netdata" > /usr/share/applications/netdata.desktop && \
chmod +x /usr/share/applications/netdata.desktop && \
# Remove mail and logout desktop icons
# rm /usr/share/applications/xfce4-mail-reader.desktop && \
rm /usr/share/applications/xfce4-session-logout.desktop
# Copy resources into workspace
COPY resources/tools $RESOURCES_PATH/tools
COPY resources/tests $RESOURCES_PATH/tests
COPY resources/tutorials $RESOURCES_PATH/tutorials
COPY resources/licenses $RESOURCES_PATH/licenses
COPY resources/reports $RESOURCES_PATH/reports
# Various configurations
RUN \
touch $HOME/.ssh/config && \
# clear chome init file - not needed since we load settings manually
chmod -R a+rwx $WORKSPACE_HOME && \
chmod -R a+rwx $RESOURCES_PATH && \
# make all desktop launchers executable
chmod -R a+rwx /usr/share/applications/ && \
ln -s $RESOURCES_PATH/tools/ $HOME/Desktop/Tools && \
ln -s $WORKSPACE_HOME $HOME/Desktop/workspace && \
chmod a+rwx /usr/local/bin/start-notebook.sh && \
chmod a+rwx /usr/local/bin/start.sh && \
chmod a+rwx /usr/local/bin/start-singleuser.sh && \
chown root:root /tmp && \
chmod 1777 /tmp && \
# TODO: does 1777 work fine? chmod a+rwx /tmp && \
# Set /workspace as default directory to navigate to as root user
echo 'cd '$WORKSPACE_HOME >> $HOME/.bashrc
# MKL and Hardware Optimization
# Fix problem with MKL with duplicated libiomp5: https://github.com/dmlc/xgboost/issues/1715
# Alternative - use openblas instead of Intel MKL: conda install -y nomkl
# http://markus-beuckelmann.de/blog/boosting-numpy-blas.html
# MKL:
# https://software.intel.com/en-us/articles/tips-to-improve-performance-for-popular-deep-learning-frameworks-on-multi-core-cpus
# https://github.com/intel/pytorch#bkm-on-xeon
# http://astroa.physics.metu.edu.tr/MANUALS/intel_ifc/mergedProjects/optaps_for/common/optaps_par_var.htm
# https://www.tensorflow.org/guide/performance/overview#tuning_mkl_for_the_best_performance
# https://software.intel.com/en-us/articles/maximize-tensorflow-performance-on-cpu-considerations-and-recommendations-for-inference
ENV KMP_DUPLICATE_LIB_OK="True" \
# Control how to bind OpenMP* threads to physical processing units # verbose
KMP_AFFINITY="granularity=fine,compact,1,0" \
KMP_BLOCKTIME=0 \
# KMP_BLOCKTIME="1" -> is not faster in my tests
# TensorFlow uses less than half the RAM with tcmalloc relative to the default. - requires google-perftools
# Too many issues: LD_PRELOAD="/usr/lib/libtcmalloc.so.4" \
# TODO set PYTHONDONTWRITEBYTECODE
# TODO set XDG_CONFIG_HOME, CLICOLOR?
# https://software.intel.com/en-us/articles/getting-started-with-intel-optimization-for-mxnet
# KMP_AFFINITY=granularity=fine, noduplicates,compact,1,0
# MXNET_SUBGRAPH_BACKEND=MKLDNN
# TODO: check https://github.com/oneapi-src/oneTBB/issues/190
# TODO: https://github.com/pytorch/pytorch/issues/37377
# use omp
MKL_THREADING_LAYER=GNU \
# To avoid over-subscription when using TBB, let the TBB schedulers use Inter Process Communication to coordinate:
ENABLE_IPC=1 \
# will cause pretty_errors to check if it is running in an interactive terminal
PYTHON_PRETTY_ERRORS_ISATTY_ONLY=1 \
# TODO: evaluate - Deactivate hdf5 file locking
HDF5_USE_FILE_LOCKING=False
# Set default values for environment variables
ENV CONFIG_BACKUP_ENABLED="true" \
SHUTDOWN_INACTIVE_KERNELS="false" \
SHARED_LINKS_ENABLED="true" \
AUTHENTICATE_VIA_JUPYTER="false" \
DATA_ENVIRONMENT=$WORKSPACE_HOME"/environment" \
WORKSPACE_BASE_URL="/" \
INCLUDE_TUTORIALS="true" \
# Main port used for sshl proxy -> can be changed
WORKSPACE_PORT="8080" \
# Set zsh as default shell (e.g. in jupyter)
SHELL="/usr/bin/zsh" \
# Fix dark blue color for ls command (unreadable):
# https://askubuntu.com/questions/466198/how-do-i-change-the-color-for-directories-with-ls-in-the-console
# USE default LS_COLORS - Dont set LS COLORS - overwritten in zshrc
# LS_COLORS="" \
# set number of threads various programs should use, if not-set, it tries to use all
# this can be problematic since docker restricts CPUs by stil showing all
MAX_NUM_THREADS="auto"
### END CONFIGURATION ###
ARG ARG_BUILD_DATE="unknown"
ARG ARG_VCS_REF="unknown"
ARG ARG_WORKSPACE_VERSION="0.15.0"
ARG ARG_WORKSPACE_FLAVOR="minimal"
#ENV WORKSPACE_VERSION=$ARG_WORKSPACE_VERSION
ENV WORKSPACE_VERSION="0.15.0"
# Overwrite & add Labels
LABEL \
"maintainer"="[email protected]" \
"workspace.version"=$WORKSPACE_VERSION \
"workspace.flavor"=$WORKSPACE_FLAVOR \
# Kubernetes Labels
"io.k8s.description"="All-in-one web-based development environment for machine learning." \
"io.k8s.display-name"="Machine Learning Workspace" \
# Openshift labels: https://docs.okd.io/latest/creating_images/metadata.html
"io.openshift.expose-services"="8080:http, 5901:xvnc" \
"io.openshift.non-scalable"="true" \
"io.openshift.tags"="workspace, machine learning, vnc, ubuntu, xfce" \
"io.openshift.min-memory"="1Gi" \
# Open Container labels: https://github.com/opencontainers/image-spec/blob/master/annotations.md
"org.opencontainers.image.title"="Machine Learning Workspace" \
"org.opencontainers.image.description"="All-in-one web-based development environment for machine learning." \
"org.opencontainers.image.documentation"="https://github.com/ml-tooling/ml-workspace" \
"org.opencontainers.image.url"="https://github.com/ml-tooling/ml-workspace" \
"org.opencontainers.image.source"="https://github.com/ml-tooling/ml-workspace" \
# "org.opencontainers.image.licenses"="Apache-2.0" \
"org.opencontainers.image.version"=$WORKSPACE_VERSION \
"org.opencontainers.image.vendor"="ML Tooling" \
"org.opencontainers.image.authors"="Lukas Masuch & Benjamin Raethlein" \
"org.opencontainers.image.revision"=$ARG_VCS_REF \
"org.opencontainers.image.created"=$ARG_BUILD_DATE \
# Label Schema Convention (deprecated): http://label-schema.org/rc1/
"org.label-schema.name"="Machine Learning Workspace" \
"org.label-schema.description"="All-in-one web-based development environment for machine learning." \
"org.label-schema.usage"="https://github.com/ml-tooling/ml-workspace" \
"org.label-schema.url"="https://github.com/ml-tooling/ml-workspace" \
"org.label-schema.vcs-url"="https://github.com/ml-tooling/ml-workspace" \
"org.label-schema.vendor"="ML Tooling" \
"org.label-schema.version"=$WORKSPACE_VERSION \
"org.label-schema.schema-version"="1.0" \
"org.label-schema.vcs-ref"=$ARG_VCS_REF \
"org.label-schema.build-date"=$ARG_BUILD_DATE
# Removed - is run during startup since a few env variables are dynamically changed: RUN printenv > $HOME/.ssh/environment
# This assures we have a volume mounted even if the user forgot to do bind mount.
# So that they do not lose their data if they delete the container.
# TODO: VOLUME [ "/workspace" ]
# TODO: WORKDIR /workspace?
# use global option with tini to kill full process groups: https://github.com/krallin/tini#process-group-killing
ENTRYPOINT ["/tini", "-g", "--"]
CMD ["python", "/resources/docker-entrypoint.py"]
# Port 8080 is the main access port (also includes SSH)
# Port 5091 is the VNC port
# Port 3389 is the RDP port
# Port 8090 is the Jupyter Notebook Server
# See supervisor.conf for more ports
EXPOSE 8080
###