Skip to content

Commit

Permalink
updated dockerfile to use last 22.04 base image from Mathworks
Browse files Browse the repository at this point in the history
  • Loading branch information
betolink committed Jun 29, 2023
1 parent 2a9a534 commit a859884
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
68 changes: 31 additions & 37 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright 2021-2023 The MathWorks, Inc.
# Copyright 2023 The MathWorks, Inc.
# Builds Docker image with
# 1. MATLAB - Using MPM
# 2. MATLAB Integration for Jupyter
# on a base image of jupyter/base-notebook.
# on a base image of jupyter/base-notebook:ubuntu-22.04

## Sample Build Command:
# docker build --build-arg MATLAB_RELEASE=r2023a \
Expand All @@ -14,8 +14,7 @@
ARG MATLAB_RELEASE=r2023a

# Specify the list of products to install into MATLAB,
ARG MATLAB_PRODUCT_LIST="MATLAB"

ARG MATLAB_PRODUCT_LIST="MATLAB Deep_Learning_Toolbox Image_Processing_Toolbox Statistics_and_Machine_Learning_Toolbox Simulink"
# Optional Network License Server information
ARG LICENSE_SERVER

Expand All @@ -25,11 +24,14 @@ ARG SHOULD_USE_LICENSE_SERVER=${LICENSE_SERVER:+"_with_lm"}
# Default DDUX information
ARG MW_CONTEXT_TAGS=MATLAB_PROXY:JUPYTER:MPM:V1


## jupyter/base-notebook:python-3.10 is based on Ubuntu 22.04 and is being used as,
## the matlabengineforpython for R2023a only supports upto python v3.10
# Base Jupyter image without LICENSE_SERVER
FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image
FROM jupyter/base-notebook:python-3.10 AS base_jupyter_image

# Base Jupyter image with LICENSE_SERVER
FROM jupyter/base-notebook:ubuntu-20.04 AS base_jupyter_image_with_lm
FROM jupyter/base-notebook:python-3.10 AS base_jupyter_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}
Expand All @@ -44,26 +46,29 @@ ARG MATLAB_PRODUCT_LIST
USER root
ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC"

## Installing Dependencies for Ubuntu 20.04
# For MATLAB : Get base-dependencies.txt from matlab-deps repository on GitHub
# For mpm : wget, unzip, ca-certificates
# For MATLAB Integration for Jupyter : xvfb
# 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"
# List of MATLAB Dependencies for Ubuntu 22.04 and MATLAB R2023a
ARG MATLAB_DEPS_REQUIREMENTS="ca-certificates libasound2 libc6 libcairo-gobject2 libcairo2 libcap2 libcrypt1 libcups2 libdrm2 libgbm1 libgdk-pixbuf-2.0-0 libgl1 libglib2.0-0 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0 libice6 libnspr4 libnss3 libodbc2 libodbcinst2 libpam0g libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libsndfile1 libuuid1 libwayland-client0 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxft2 libxinerama1 libxrandr2 libxt6 libxtst6 libxxf86vm1 locales locales-all make net-tools procps sudo unzip zlib1g"
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 \
## Install dependencies
## MATLAB versions older than 22b need libpython3.9 which is only present in the deadsnakes PPA on ubuntu:22.04
RUN echo ${MATLAB_DEPS_REQUIREMENTS} > ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} \
&& apt-get update \
&& export isJammy=`cat /etc/lsb-release | grep DISTRIB_RELEASE=22.04 | wc -l` \
&& export needsPy39=`cat ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} | grep libpython3.9 | wc -l` \
&& if [[ isJammy -eq 1 && needsPy39 -eq 1 ]] ; then apt-get install -y software-properties-common && add-apt-repository ppa:deadsnakes/ppa ; fi \
&& xargs -a ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME} -r apt-get install --no-install-recommends -y \
wget \
unzip \
ca-certificates \
xvfb \
git \
&& apt-get clean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/* ${MATLAB_DEPS_REQUIREMENTS_FILE_NAME}

# Note on glibc patch - See https://github.com/mathworks/build-glibc-bz-19329-patch
# Installation is skipped on Ubuntu 22.04 (Jammy) as it already contains the glibc fix

# Run mpm to install MATLAB in the target location and delete the mpm installation afterwards
RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \
chmod +x mpm && \
Expand All @@ -74,39 +79,33 @@ RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm && \
rm -f mpm /tmp/mathworks_root.log && \
ln -s /opt/matlab/bin/matlab /usr/local/bin/matlab

# 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 /

# Optional: Install MATLAB Engine for Python, if possible.
# Note: Failure to install does not stop the build.
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update \
RUN apt-get update \
&& apt-get install --no-install-recommends -y python3-distutils \
&& apt-get clean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/* \
&& cd /opt/matlab/extern/engines/python \
&& python setup.py install || true
&& python setup.py install

# Switch back to notebook user
USER $NB_USER

# Install integration
RUN python -m pip install jupyter-matlab-proxy

# Make JupyterLab the default environment
ENV JUPYTER_ENABLE_LAB="yes"

ENV MW_CONTEXT_TAGS=${MW_CONTEXT_TAGS}


COPY . /tmp/build
## Conda environment for Openscapes

ENV CONDA_ENV="openscapes"
ENV PYTHON_PREFIX=/opt/conda

COPY . /tmp/build
WORKDIR /tmp/build

RUN echo "Checking for 'conda-linux-64.lock' or 'environment.yml'..." \
Expand All @@ -124,12 +123,7 @@ RUN echo "Checking for 'conda-linux-64.lock' or 'environment.yml'..." \
; if [ -d ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static ]; then \
find ${NB_PYTHON_PREFIX}/lib/python*/site-packages/bokeh/server/static -follow -type f -name '*.js' ! -name '*.min.js' -delete \
; fi
RUN python -m pip install jupyter-matlab-proxy

# Switch back to notebook user
USER $NB_USER
WORKDIR /home/${NB_USER}

# Install integration

EXPOSE 8888
2 changes: 1 addition & 1 deletion ci/MATLAB_TOOLBOXES.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MATLAB Deep_Learning_Toolbox
MATLAB Deep_Learning_Toolbox Parallel_Computing_Toolbox Mapping_Toolbox

0 comments on commit a859884

Please sign in to comment.