generated from gsoc2/ml-workspace
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
824 lines (729 loc) · 30.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
# Stage 1: Build stage
FROM ubuntu:22.04 AS build
USER root
### BASICS ###
# Technical Environment Variables
ENV \
SHELL="/bin/bash" \
HOME="/root" \
# Notebook 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"
# Install basics
RUN \
apt-get update --fix-missing && \
apt-get install -y sudo apt-utils && \
apt-get upgrade -y && \
apt-get update && \
apt-get install -y --no-install-recommends \
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 \
libreadline-dev \
libedit-dev \
xz-utils \
gawk \
swig \
graphviz \
libgraphviz-dev \
screen \
nano \
locate \
sqlite3 \
xmlstarlet \
parallel \
libspatialindex-dev \
yara \
libhiredis-dev \
libpq-dev \
libmysqlclient-dev \
libleptonica-dev \
libgeos-dev \
less \
tree \
bash-completion \
iputils-ping \
socat \
jq \
rsync \
libsqlite3-dev \
git \
subversion \
jed \
unixodbc \
unixodbc-dev \
libtiff-dev \
libjpeg-dev \
libpng-dev \
libglib2.0-0 \
libxext6 \
libsm6 \
libxext-dev \
libxrender1 \
libzmq3-dev \
protobuf-compiler \
libprotobuf-dev \
libprotoc-dev \
autoconf \
automake \
libtool \
cmake \
fonts-liberation \
google-perftools \
zip \
gzip \
unzip \
bzip2 \
lzop \
libarchive-tools \
unp \
libbz2-dev \
liblzma-dev \
zlib1g-dev && \
add-apt-repository -y ppa:git-core/ppa && \
apt-get update && \
apt-get install -y --no-install-recommends git && \
chmod -R a+rwx /usr/local/bin/ && \
ldconfig && \
fix-permissions.sh $HOME && \
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 \
autossh \
mussh && \
chmod go-w $HOME && \
mkdir -p $HOME/.ssh/ && \
touch $HOME/.ssh/config && \
sudo chown -R $NB_USER:users $HOME/.ssh && \
chmod 700 $HOME/.ssh && \
printenv >> $HOME/.ssh/environment && \
chmod -R a+rwx /usr/local/bin/ && \
fix-permissions.sh $HOME && \
clean-layer.sh
RUN \
OPEN_RESTY_VERSION="1.19.3.2" && \
mkdir $RESOURCES_PATH"/openresty" && \
cd $RESOURCES_PATH"/openresty" && \
apt-get update && \
apt-get purge -y nginx nginx-common && \
apt-get install -y libssl-dev 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/ && \
./configure --with-http_stub_status_module --with-http_sub_module > /dev/null && \
make -j2 > /dev/null && \
make install > /dev/null && \
mkdir -p /var/log/nginx/ && \
touch /var/log/nginx/upstream.log && \
cd $RESOURCES_PATH && \
rm -r $RESOURCES_PATH"/openresty" && \
chmod -R a+rwx $RESOURCES_PATH && \
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 \
CONDA_DIR=/opt/conda \
CONDA_ROOT=/opt/conda \
PYTHON_VERSION="3.10.4" \
CONDA_PYTHON_DIR=/opt/conda/lib/python3.10 \
MINICONDA_VERSION=4.10.3 \
MINICONDA_MD5=122c8c9beb51e124ab32a0fa6426c656 \
CONDA_VERSION=4.9.2
# Install a more recent version of Conda
RUN wget --no-verbose https://repo.anaconda.com/miniconda/Miniconda3-py38_${CONDA_VERSION}-Linux-x86_64.sh -O ~/miniconda.sh && \
echo "${MINICONDA_MD5} *miniconda.sh" | md5sum -c - && \
/bin/bash ~/miniconda.sh -b -p $CONDA_ROOT && \
rm ~/miniconda.sh && \
$CONDA_ROOT/bin/conda init bash && \
export PATH=$CONDA_ROOT/bin:$PATH && \
$CONDA_ROOT/bin/conda update -y conda && \
$CONDA_ROOT/bin/conda install -y conda-build && \
$CONDA_ROOT/bin/conda install -y python=${PYTHON_VERSION} && \
ln -s $CONDA_ROOT/bin/python /usr/local/bin/python && \
ln -s $CONDA_ROOT/bin/conda /usr/bin/conda && \
$CONDA_ROOT/bin/conda install -y pip && \
$CONDA_ROOT/bin/pip install --upgrade pip && \
chmod -R a+rwx /usr/local/bin/
ENV PATH=$CONDA_ROOT/bin:$PATH
ENV RESOURCES_PATH=/opt/resources
ENV LD_LIBRARY_PATH=$CONDA_ROOT/lib
# Install pyenv to allow dynamic creation of python versions
RUN apt-get update && \
apt-get install -y --no-install-recommends git libffi-dev && \
git clone https://github.com/pyenv/pyenv.git $RESOURCES_PATH/.pyenv && \
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 && \
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 && \
python -m pipx ensurepath && \
clean-layer.sh
ENV PATH=$HOME/.local/bin:$PATH
# Install node.js
RUN \
apt-get update && \
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - && \
apt-get install -y nodejs && \
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 && \
chmod a+rwx /usr/bin/node && \
chmod a+rwx /usr/bin/npm && \
mkdir -p /opt/node/bin && \
ln -s /usr/bin/node /opt/node/bin/node && \
ln -s /usr/bin/npm /opt/node/bin/npm && \
/usr/bin/npm install -g npm && \
/usr/bin/npm install -g yarn && \
/usr/bin/npm install -g typescript && \
/usr/bin/npm install -g webpack && \
/usr/bin/npm install -g node-gyp && \
/usr/bin/npm update -g && \
clean-layer.sh
ENV PATH=/opt/node/bin:$PATH
### END RUNTIMES ###
### PROCESS TOOLS ###
# Install supervisor for process supervision
RUN \
apt-get update && \
mkdir -p /var/run/sshd && chmod 400 /var/run/sshd && \
apt-get install -y --no-install-recommends rsyslog && \
pipx install supervisor && \
pipx inject supervisor supervisor-stdout && \
mkdir -p /var/log/supervisor/ && \
clean-layer.sh
### END PROCESS TOOLS ###
### GUI TOOLS ###
# Install xfce4 & gui tools
RUN \
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 && \
apt-get install -y --no-install-recommends xauth xinit dbus-x11 && \
apt-get install -y --no-install-recommends gdebi && \
apt-get install -y --no-install-recommends catfish && \
apt-get install -y --no-install-recommends font-manager && \
apt-get install -y thunar-vcs-plugin && \
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 && \
apt-get install -y --no-install-recommends baobab && \
apt-get install -y --no-install-recommends mousepad && \
apt-get install -y --no-install-recommends vim && \
apt-get install -y --no-install-recommends htop && \
apt-get install -y p7zip p7zip-rar && \
apt-get install -y --no-install-recommends thunar-archive-plugin && \
apt-get install -y xarchiver && \
apt-get install -y --no-install-recommends sqlitebrowser && \
apt-get install -y --no-install-recommends nautilus && \
apt-get install -y --no-install-recommends gigolo && \
apt-get install -y --no-install-recommends gftp && \
add-apt-repository -y ppa:saiarcot895/chromium-beta && \
apt-get update && \
apt-get install -y --no-install-recommends chromium-browser --no-install-recommends chromium-browser-l10n --no-install-recommends chromium-codecs-ffmpeg
ln -s /usr/bin/chromium-browser /usr/bin/google-chrome && \
apt-get purge -y pm-utils xscreensaver* && \
apt-get remove -y app-install-data gnome-user-guide && \
clean-layer.sh
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} && \
wget -qO- https://sourceforge.net/projects/tigervnc/files/stable/1.11.0/tigervnc-1.11.0.x86_64.tar.gz/download | tar xz --strip 1 -C / && \
mkdir -p ./novnc/utils/websockify && \
wget -qO- https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz | tar xz --strip 1 -C ./novnc && \
wget -qO- https://github.com/novnc/websockify/archive/v0.9.0.tar.gz | tar xz --strip 1 -C ./novnc/utils/websockify && \
chmod +x -v ./novnc/utils/*.sh && \
mkdir -p $HOME/.vnc && \
fix-permissions.sh ${RESOURCES_PATH} && \
clean-layer.sh
# Install Web Tools - Offered via Jupyter Tooling Plugin
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs
RUN node -v
## 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 && \
clean-layer.sh
## ungit
COPY resources/tools/ungit.sh $RESOURCES_PATH/tools/ungit.sh
RUN \
/bin/bash $RESOURCES_PATH/tools/ungit.sh --install && \
clean-layer.sh
## netdata
COPY resources/tools/netdata.sh $RESOURCES_PATH/tools/netdata.sh
RUN \
/bin/bash $RESOURCES_PATH/tools/netdata.sh --install && \
clean-layer.sh
## Glances webtool is installed in python section below via requirements.txt
## Filebrowser
COPY resources/tools/filebrowser.sh $RESOURCES_PATH/tools/filebrowser.sh
RUN \
/bin/bash $RESOURCES_PATH/tools/filebrowser.sh --install && \
clean-layer.sh
ARG ARG_WORKSPACE_FLAVOR="full"
ENV WORKSPACE_FLAVOR=$ARG_WORKSPACE_FLAVOR
# Install Firefox
COPY resources/tools/firefox.sh $RESOURCES_PATH/tools/firefox.sh
RUN \
if [ "$WORKSPACE_FLAVOR" = "minimal" ]; then \
exit 0 ; \
fi && \
/bin/bash $RESOURCES_PATH/tools/firefox.sh --install && \
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
# Install main data science libs
RUN \
ln -s -f $CONDA_ROOT/bin/python /usr/bin/python && \
apt-get update && apt-get install -y --no-install-recommends \
libopenmpi-dev \
openmpi-bin \
liblapack-dev \
libatlas-base-dev \
libeigen3-dev \
libblas-dev \
libhdf5-dev \
libtbb-dev \
libtesseract-dev \
libopenexr-dev \
libgomp1 && \
pip install --upgrade pip && \
conda config --system --set channel_priority strict && \
if [ "$WORKSPACE_FLAVOR" = "minimal" ]; then \
conda install -y --update-all "python=$PYTHON_VERSION" nomkl && \
pip install --no-cache-dir -r ${RESOURCES_PATH}/libraries/requirements-minimal.txt && \
fix-permissions.sh $CONDA_ROOT && \
clean-layer.sh && \
exit 0 ; \
fi && \
if [ "$WORKSPACE_FLAVOR" != "minimal" ]; then \
conda install -y --update-all "python=$PYTHON_VERSION" mkl-service mkl && \
conda install -y --freeze-installed \
boost \
mkl-include && \
conda install -y -c mingfeima mkldnn && \
conda install -y -c pytorch "pytorch==1.10.*" cpuonly && \
conda install -y --freeze-installed \
'ipython' \
'notebook' \
'jupyterlab' \
'nbconvert' \
'yarl' \
'scipy' \
'numpy' \
scikit-learn \
numexpr && \
pip install --no-cache-dir -r ${RESOURCES_PATH}/libraries/requirements-light.txt && \
fix-permissions.sh $CONDA_ROOT && \
clean-layer.sh && \
exit 0 ; \
fi && \
if [ "$WORKSPACE_FLAVOR" = "full" ]; then \
conda install -y --freeze-installed \
libjpeg-turbo && \
conda install -y -c bioconda -c conda-forge snakemake-minimal && \
conda install -y -c conda-forge mamba && \
conda install -y --no-deps --freeze-installed faiss-cpu
pip install --no-cache-dir --use-deprecated=legacy-resolver \
-r ${RESOURCES_PATH}/libraries/requirements-full.txt && \
python -m spacy download en ; \
fi && \
fix-permissions.sh $CONDA_ROOT && \
clean-layer.sh && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Fix conda version
RUN \
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 \
mkdir -p $HOME/.jupyter/nbconfig/ && \
printf "{\"load_extensions\": {}}" > $HOME/.jupyter/nbconfig/notebook.json && \
jupyter contrib nbextension install --sys-prefix && \
jupyter nbextensions_configurator enable --sys-prefix && \
nbdime config-git --enable --global && \
jupyter nbextension enable --py jupytext --sys-prefix && \
jupyter nbextension enable skip-traceback/main --sys-prefix && \
jupyter nbextension enable toc2/main --sys-prefix && \
jupyter nbextension enable execute_time/ExecuteTime --sys-prefix && \
jupyter nbextension enable collapsible_headings/main --sys-prefix && \
jupyter nbextension enable codefolding/main --sys-prefix && \
jupyter nbextension disable pydeck/extension && \
pip install --no-cache-dir git+https://github.com/InfuseAI/jupyter_tensorboard.git && \
jupyter tensorboard enable --sys-prefix && \
cat $HOME/.jupyter/nbconfig/notebook.json | jq '.toc2={"moveMenuLeft": false,"widenNotebook": false,"skip_h1_title": false,"sideBar": true,"number_sections": false,"collapse_to_match_collapsible_headings": true}' > tmp.$$.json && mv tmp.$$.json $HOME/.jupyter/nbconfig/notebook.json && \
if [ "$WORKSPACE_FLAVOR" = "minimal" ]; then \
clean-layer.sh && \
exit 0 ; \
fi && \
jupyter nbextension install https://github.com/drillan/jupyter-black/archive/master.zip --sys-prefix && \
jupyter nbextension enable jupyter-black-master/jupyter-black --sys-prefix && \
if [ "$WORKSPACE_FLAVOR" = "light" ]; then \
clean-layer.sh && \
exit 0 ; \
fi && \
pip install witwidget && \
jupyter nbextension install --py --symlink --sys-prefix witwidget && \
jupyter nbextension enable --py --sys-prefix witwidget && \
jupyter nbextension enable --py --sys-prefix qgrid && \
ipcluster nbextension enable && \
clean-layer.sh
# install jupyterlab
RUN \
npm install -g es6-promise && \
jupyter lab build && \
lab_ext_install='jupyter labextension install -y --debug-log-path=/dev/stdout --log-level=WARN --minimize=False --no-build' && \
$lab_ext_install @jupyter-widgets/jupyterlab-manager && \
if [ "$WORKSPACE_FLAVOR" = "minimal" ]; then \
jupyter lab build -y --debug-log-path=/dev/stdout --log-level=WARN && \
jupyter lab clean && \
jlpm cache clean && \
rm -rf $CONDA_ROOT/share/jupyter/lab/staging && \
clean-layer.sh && \
exit 0 ; \
fi && \
$lab_ext_install @jupyterlab/toc && \
pip install git+https://github.com/chaoleili/jupyterlab_tensorboard.git && \
pip install jupyterlab-git && \
if [ "$WORKSPACE_FLAVOR" = "light" ]; then \
jupyter lab build -y --debug-log-path=/dev/stdout --log-level=WARN && \
jupyter lab clean && \
jlpm cache clean && \
rm -rf $CONDA_ROOT/share/jupyter/lab/staging && \
clean-layer.sh && \
exit 0 ; \
fi \
&& pip install jupyterlab-lsp==3.7.0 jupyter-lsp==1.3.0 && \
$lab_ext_install jupyterlab-plotly && \
$lab_ext_install install @jupyter-widgets/jupyterlab-manager plotlywidget && \
$lab_ext_install jupyterlab-chart-editor && \
pip install lckr-jupyterlab-variableinspector && \
$lab_ext_install @ryantam626/jupyterlab_code_formatter && \
pip install jupyterlab_code_formatter && \
jupyter serverextension enable --py jupyterlab_code_formatter \
&& jupyter lab build -y --debug-log-path=/dev/stdout --log-level=WARN && \
jupyter lab build && \
jupyter lab clean && \
jlpm cache clean && \
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 && \
clean-layer.sh
# Install and activate ZSH
COPY resources/tools/oh-my-zsh.sh $RESOURCES_PATH/tools/oh-my-zsh.sh
RUN \
/bin/bash $RESOURCES_PATH/tools/oh-my-zsh.sh --install && \
conda init zsh && \
chsh -s $(which zsh) $NB_USER && \
curl -s https://get.sdkman.io | bash && \
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 && \
clean-layer.sh
### VSCODE ###
# Install vscode extension
RUN \
SLEEP_TIMER=25 && \
if [ "$WORKSPACE_FLAVOR" = "minimal" ]; then \
exit 0 ; \
fi && \
cd $RESOURCES_PATH && \
mkdir -p $HOME/.vscode/extensions/ && \
VS_JUPYTER_VERSION="2021.6.832593372" && \
wget --retry-on-http-error=429 --waitretry 15 --tries 5 --no-verbose https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-toolsai/vsextensions/jupyter/$VS_JUPYTER_VERSION/vspackage -O ms-toolsai.jupyter-$VS_JUPYTER_VERSION.vsix && \
bsdtar -xf ms-toolsai.jupyter-$VS_JUPYTER_VERSION.vsix extension && \
rm ms-toolsai.jupyter-$VS_JUPYTER_VERSION.vsix && \
mv extension $HOME/.vscode/extensions/ms-toolsai.jupyter-$VS_JUPYTER_VERSION && \
sleep $SLEEP_TIMER && \
VS_PYTHON_VERSION="2021.5.926500501" && \
wget --no-verbose https://github.com/microsoft/vscode-python/releases/download/$VS_PYTHON_VERSION/ms-python-release.vsix && \
bsdtar -xf ms-python-release.vsix extension && \
rm ms-python-release.vsix && \
mv extension $HOME/.vscode/extensions/ms-python.python-$VS_PYTHON_VERSION && \
sleep $SLEEP_TIMER && \
if [ "$WORKSPACE_FLAVOR" = "light" ]; then \
exit 0 ; \
fi && \
PRETTIER_VERSION="6.4.0" && \
wget --no-verbose https://github.com/prettier/prettier-vscode/releases/download/v$PRETTIER_VERSION/prettier-vscode-$PRETTIER_VERSION.vsix && \
bsdtar -xf prettier-vscode-$PRETTIER_VERSION.vsix extension && \
rm prettier-vscode-$PRETTIER_VERSION.vsix && \
mv extension $HOME/.vscode/extensions/prettier-vscode-$PRETTIER_VERSION && \
VS_CODE_RUNNER_VERSION="0.9.17" && \
wget --no-verbose https://github.com/formulahendry/vscode-code-runner/releases/download/$VS_CODE_RUNNER_VERSION/code-runner-$VS_CODE_RUNNER_VERSION.vsix && \
bsdtar -xf code-runner-$VS_CODE_RUNNER_VERSION.vsix extension && \
rm code-runner-$VS_CODE_RUNNER_VERSION.vsix && \
mv extension $HOME/.vscode/extensions/code-runner-$VS_CODE_RUNNER_VERSION && \
sleep $SLEEP_TIMER && \
VS_ESLINT_VERSION="2.1.23" && \
wget --retry-on-http-error=429 --waitretry 15 --tries 5 --no-verbose https://marketplace.visualstudio.com/_apis/public/gallery/publishers/dbaeumer/vsextensions/vscode-eslint/$VS_ESLINT_VERSION/vspackage -O dbaeumer.vscode-eslint.vsix && \
bsdtar -xf dbaeumer.vscode-eslint.vsix extension && \
rm dbaeumer.vscode-eslint.vsix && \
mv extension $HOME/.vscode/extensions/dbaeumer.vscode-eslint-$VS_ESLINT_VERSION && \
fix-permissions.sh $HOME/.vscode/extensions/ && \
clean-layer.sh
### END VSCODE ###
### INCUBATION ZONE ###
RUN \
apt-get update && \
if [ "$WORKSPACE_FLAVOR" = "minimal" ] || [ "$WORKSPACE_FLAVOR" = "light" ]; then \
clean-layer.sh && \
exit 0 ; \
fi && \
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 \
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 \
cp -f $RESOURCES_PATH/branding/logo.png $CONDA_PYTHON_DIR"/site-packages/notebook/static/base/images/logo.png" && \
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" && \
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 && \
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
# Configure Matplotlib
RUN \
MPLBACKEND=Agg python -c "import matplotlib.pyplot" \
sed -i "s/^.*Matplotlib is building the font cache using fc-list.*$/# Warning removed/g" $CONDA_PYTHON_DIR/site-packages/matplotlib/font_manager.py
# Create Desktop Icons for Tooling
COPY resources/icons $RESOURCES_PATH/icons
RUN \
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 && \
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 && \
echo "[Desktop Entry]\nVersion=1.0\nType=Link\nName=Glances\nComment=Hardware Monitoring\nCategories=System;Utility;\nIcon=/resources/icons/glances-icon.png\nURL=http://localhost:8092/tools/glances" > /usr/share/applications/glances.desktop && \
chmod +x /usr/share/applications/glances.desktop && \
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 && \
chmod -R a+rwx $WORKSPACE_HOME && \
chmod -R a+rwx $RESOURCES_PATH && \
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 && \
echo 'cd '$WORKSPACE_HOME >> $HOME/.bashrc
ENV KMP_DUPLICATE_LIB_OK="True" \
KMP_AFFINITY="granularity=fine,compact,1,0" \
KMP_BLOCKTIME=0 \
MKL_THREADING_LAYER=GNU \
ENABLE_IPC=1 \
PYTHON_PRETTY_ERRORS_ISATTY_ONLY=1 \
HDF5_USE_FILE_LOCKING=False
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" \
WORKSPACE_PORT="8080" \
SHELL="/usr/bin/zsh" \
MAX_NUM_THREADS="auto"
### END CONFIGURATION ###
ARG ARG_BUILD_DATE="unknown"
ARG ARG_VCS_REF="unknown"
ARG ARG_WORKSPACE_VERSION="unknown"
ENV WORKSPACE_VERSION=$ARG_WORKSPACE_VERSION
# Overwrite & add Labels
LABEL \
"maintainer"="[email protected]" \
"workspace.version"=$WORKSPACE_VERSION \
"workspace.flavor"=$WORKSPACE_FLAVOR \
"io.k8s.description"="All-in-one web-based development environment for machine learning." \
"io.k8s.display-name"="Machine Learning Workspace" \
"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" \
"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/khulnasoft/ml-workspace" \
"org.opencontainers.image.url"="https://github.com/khulnasoft/ml-workspace" \
"org.opencontainers.image.source"="https://github.com/khulnasoft/ml-workspace" \
"org.opencontainers.image.version"=$WORKSPACE_VERSION \
"org.opencontainers.image.vendor"="KhulnaSoft DevOps" \
"org.opencontainers.image.authors"="Md Sulaiman & KhulnaSoft Lab" \
"org.opencontainers.image.revision"=$ARG_VCS_REF \
"org.opencontainers.image.created"=$ARG_BUILD_DATE \
"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/khulnasoft/ml-workspace" \
"org.label-schema.url"="https://github.com/khulnasoft/ml-workspace" \
"org.label-schema.vcs-url"="https://github.com/khulnasoft/ml-workspace" \
"org.label-schema.vendor"="Khulnasoft DevOps" \
"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
# Stage 2: Runtime stage
FROM ubuntu:22.04 AS runtime
COPY --from=build / /
ENTRYPOINT ["/tini", "-g", "--"]
CMD ["python", "/resources/docker-entrypoint.py"]
EXPOSE 8080