-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.mounted
128 lines (102 loc) · 5.12 KB
/
Dockerfile.mounted
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
# Copyright 2021-2023 The MathWorks, Inc.
# Builds Docker image with
# 1. MATLAB Integration for Jupyter (VNC)
# on a base image of jupyter/base-notebook.
# Folder with the MATLAB installation needs to be mounted into the image at /opt/matlab
## Sample Build Command:
# docker build --build-arg MATLAB_RELEASE=r2023a \
# --build-arg LICENSE_SERVER=12345@hostname.com \
# -t my_matlab_image_name .
# Specify release of MATLAB being mounted. (use lowercase, default is r2023a)
# Used to fetch & install MATLAB's s/w dependencies
ARG MATLAB_RELEASE=r2023a
# Optional Network License Server information in the form of port@hostname
ARG LICENSE_SERVER
# If LICENSE_SERVER is provided then SHOULD_USE_LICENSE_SERVER will be set to "_use_lm"
ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"}
# Default DDUX information
ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MOUNTED:V1
# Base Jupyter image without LICENSE_SERVER
FROM jupyter/base-notebook:ubuntu-20.04 AS base_image
# Base Jupyter image with LICENSE_SERVER
FROM jupyter/base-notebook:ubuntu-20.04 AS base_image_with_lm
ARG LICENSE_SERVER
# If license server information is available, then use it to set environment variable
ENV MLM_LICENSE_FILE=${LICENSE_SERVER}
# Select base Jupyter image based on whether LICENSE_SERVER is provided
FROM base_image${SHOULD_USE_LICENSE_SERVER}
ARG MW_CONTEXT_TAGS
ARG MATLAB_RELEASE
# Switch to root user
USER root
ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC"
# Put MATLAB on the PATH
RUN ln -s /usr/local/MATLAB/bin/matlab /usr/local/bin/matlab
## Installing Dependencies for Ubuntu 20.04:
# For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub
# For MATLAB Integration for Jupyter (VNC): xvfb dbus-x11 firefox xfce4 xfce4-panel xfce4-session xfce4-settings xorg xubuntu-icon-theme curl xscreensaver
# List of MATLAB Dependencies for Ubuntu 20.04 and specified MATLAB_RELEASE
ARG MATLAB_DEPS_REQUIREMENTS_FILE="https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/ubuntu20.04/base-dependencies.txt"
ARG MATLAB_DEPS_REQUIREMENTS_FILE_NAME="matlab-deps-${MATLAB_RELEASE}-base-dependencies.txt"
# Install dependencies
RUN wget ${MATLAB_DEPS_REQUIREMENTS_FILE} -O ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} && \
export DEBIAN_FRONTEND=noninteractive && apt-get update && \
xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \
dbus-x11 \
firefox \
xfce4 \
xfce4-panel \
xfce4-session \
xfce4-settings \
xorg \
xubuntu-icon-theme \
curl \
xscreensaver \
&& apt-get remove -y gnome-screensaver \
&& apt-get clean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME}
# Install patched glibc - See https://github.com/mathworks/build-glibc-bz-19329-patch
WORKDIR /packages
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && apt-get clean && apt-get autoremove && \
wget -q https://github.com/mathworks/build-glibc-bz-19329-patch/releases/download/ubuntu-focal/all-packages.tar.gz && \
tar -x -f all-packages.tar.gz \
--exclude glibc-*.deb \
--exclude libc6-dbg*.deb && \
apt-get install --yes --no-install-recommends --allow-downgrades ./*.deb && \
rm -fr /packages
WORKDIR /
# Install tigervnc to /usr/local
RUN curl -sSfL 'https://sourceforge.net/projects/tigervnc/files/stable/1.10.1/tigervnc-1.10.1.x86_64.tar.gz/download' \
| tar -zxf - -C /usr/local --strip=2
# noVNC provides VNC over browser capability
# Set default install location for noVNC
ARG NOVNC_PATH=/opt/noVNC
# Get noVNC
RUN mkdir -p ${NOVNC_PATH} \
&& curl -sSfL 'https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz' \
| tar -zxf - -C ${NOVNC_PATH} --strip=1 \
&& chown -R ${NB_USER}:users ${NOVNC_PATH}
# JOVYAN is the default user in jupyter/base-notebook.
# JOVYAN is being set to be passwordless.
# This allows users to easily wake the desktop when it goes to sleep.
RUN passwd $NB_USER -d
# Switch back to notebook user
USER $NB_USER
# Get websockify
RUN conda install -y -q websockify=0.10.0
# Set environment variable for python package jupyter-matlab-vnc-proxy
ENV NOVNC_PATH=${NOVNC_PATH}
# Pip install the latest version of the integration
RUN curl -s https://api.github.com/repos/mathworks/jupyter-matlab-vnc-proxy/releases/latest | grep tarball_url | cut -d '"' -f 4 | xargs python -m pip install
# Move MATLAB resource files to the expected locations
RUN export RESOURCES_LOC=$(python -c "import jupyter_matlab_vnc_proxy as pkg; print(pkg.__path__[0])")/resources \
&& mkdir -p ${HOME}/.local/share/applications ${HOME}/Desktop ${HOME}/.local/share/ ${HOME}/.icons \
&& cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/Desktop/ \
&& cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/.local/share/applications\
&& ln -s ${RESOURCES_LOC}/matlab_icon.png ${HOME}/.icons/matlab_icon.png \
&& cp ${RESOURCES_LOC}/matlab_launcher.py ${HOME}/.local/share/ \
&& cp ${RESOURCES_LOC}/mw_lite.html ${NOVNC_PATH}
# Fixes occasional failure to start VNC desktop, which requires a reloading of the webpage to fix.
RUN touch ${HOME}/.Xauthority