-
Notifications
You must be signed in to change notification settings - Fork 4
/
MIN.dockerfile
104 lines (101 loc) · 4.83 KB
/
MIN.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
#Temp Image to create exec to allow UID/GID to be updated on boot
FROM golang:alpine3.9 as go_tmp
COPY ./startup.go /startup.go
RUN cd / && go build startup.go
#Matlab Image
# USER=ROOT
FROM debian:stretch-slim as mat_build
ARG MATLAB_VERSION
ARG MATLAB_FILE_KEY
ARG MATLAB_INSTALLED_ROOT
ENV MATLAB_INSTALLED_ROOT=$MATLAB_INSTALLED_ROOT
ENV MATLAB_VERSION=$MATLAB_VERSION
COPY ./entrypoint.sh /entrypoint.sh
COPY ./installer_input.txt /home/muser/install/installer_input.txt
COPY --from=go_tmp /startup /startup
SHELL ["/bin/bash", "-c"]
RUN \
# Install Core dependencies
apt-get update && \
# depen (install, min matlab, R2019a, R2016a, R2016a, R2016b)
apt-get install -y unzip libxt6 lsb-release libncurses5-dev libxext6 libxrandr2 && \
# matlab user (muser)
export uid=3000 gid=3000 && \
mkdir -p /home/muser && \
mkdir /src && \
echo "muser:x:${uid}:${gid}:Developer,,,:/home/muser:/bin/bash" >> /etc/passwd && \
echo "muser:x:${uid}:" >> /etc/group && \
chown ${uid}:${gid} -R /home/muser && \
chown ${uid}:${gid} -R /src && \
# Setup entrypoint and startup
chmod +x /entrypoint.sh && \
chown muser:muser /home/muser/install/installer_input.txt && \
chmod 4755 /startup
# USER=MUSER
USER muser
# Install base Matlab
RUN mkdir -p /home/muser/install/matlab-files
COPY ./installers/*$MATLAB_VERSION* /home/muser/install/
RUN \
cd /home/muser/install && \
unzip *matlab*$MATLAB_VERSION*.zip -d /home/muser/install/matlab-files && \
echo "fileInstallationKey=${MATLAB_FILE_KEY}" >> /home/muser/install/installer_input.txt && \
echo "destinationFolder=${MATLAB_INSTALLED_ROOT}" >> /home/muser/install/installer_input.txt && \
cd matlab-files && \
./install -inputFile /home/muser/install/installer_input.txt && \
rm /tmp/mathworks_docker.log && \
rm -R /home/muser/install
RUN \
# Remove Matlab bloat R2018b/R2019a/R2016b
rm -R ${MATLAB_INSTALLED_ROOT}/help && \
rm -R ${MATLAB_INSTALLED_ROOT}/cefclient || echo "MATLAB ERROR: cefclient not found. Skipping..." && \
rm -R ${MATLAB_INSTALLED_ROOT}/toolbox/matlab/maps || echo "MATLAB ERROR: toolbox/matlab/maps not found. Skipping..." && \
sed -i '/toolbox\/matlab\/maps/d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
rm -R ${MATLAB_INSTALLED_ROOT}/toolbox/matlab/codetools && \
sed -i '/toolbox\/matlab\/codetools/d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
rm -R ${MATLAB_INSTALLED_ROOT}/bin/glnxa64/mkl.so && \
rm -R ${MATLAB_INSTALLED_ROOT}/toolbox/shared && \
sed -i '/toolbox\/shared/d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
rm -R ${MATLAB_INSTALLED_ROOT}/ui && \
sed -i '/ui\//d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
rm -R ${MATLAB_INSTALLED_ROOT}/examples && \
sed -i '/examples\//d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
rm -R ${MATLAB_INSTALLED_ROOT}/java/jarext/jxbrowser-chromium && \
rm -R ${MATLAB_INSTALLED_ROOT}/sys/jxbrowser && \
rm -R ${MATLAB_INSTALLED_ROOT}/toolbox/matlab/datatools || echo "MATLAB ERROR: toolbox/matlab/datatools not found. Skipping..." && \
sed -i '/toolbox\/matlab\/datatools/d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
rm -R ${MATLAB_INSTALLED_ROOT}/toolbox/matlab/appdesigner && \
sed -i '/toolbox\/matlab\/appdesigner/d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
rm -R ${MATLAB_INSTALLED_ROOT}/toolbox/matlab/demos && \
sed -i '/toolbox\/matlab\/demos/d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
rm -R ${MATLAB_INSTALLED_ROOT}/toolbox/matlab/system && \
sed -i '/toolbox\/matlab\/system/d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
rm -R ${MATLAB_INSTALLED_ROOT}/toolbox/coder || echo "MATLAB ERROR: toolbox/coder not found. Skipping..." && \
sed -i '/toolbox\/coder/d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m && \
[ "${MATLAB_VERSION}" == "R2016b" ] || rm -R ${MATLAB_INSTALLED_ROOT}/toolbox/matlab/uitools && \
[ "${MATLAB_VERSION}" == "R2016b" ] || sed -i '/toolbox\/matlab\/uitools/d' ${MATLAB_INSTALLED_ROOT}/toolbox/local/pathdef.m
# Uncomment below for R2016a (unconfirmed)
# rm -R ${MATLAB_INSTALLED_ROOT}/sys/opengl && \
# rm ${MATLAB_INSTALLED_ROOT}/toolbox/local/hgrc.m && \
# rm ${MATLAB_INSTALLED_ROOT}/bin/glnxa64/libmwhg.so
#Prepare Activation on boot
COPY ./activate.ini /home/muser/.activate.ini
#Update MATLAB cert to one that is more recent (R2019a)
COPY ./rootcerts.pem ${MATLAB_INSTALLED_ROOT}/sys/certificates/ca/
#Squashed Final Image
FROM scratch
COPY --from=mat_build / /
RUN chmod 4755 /startup
LABEL maintainerName="Raphael Guzman" \
maintainerEmail="[email protected]"
ARG MATLAB_VERSION
ARG MATLAB_INSTALLED_ROOT
USER muser
ENV MATLAB_INSTALLED_ROOT=$MATLAB_INSTALLED_ROOT
ENV MATLAB_VERSION=$MATLAB_VERSION
ENV HOME /home/muser
ENV LANG C.UTF-8
ENV PATH "$PATH:${MATLAB_INSTALLED_ROOT}/bin"
ENTRYPOINT ["/entrypoint.sh"]
WORKDIR /home/muser
CMD ["matlab","-h"]