blob: f8bfc6aed8ab2f4eb94bd563ce05b188b7a91d84 (
plain)
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
|
FROM ubuntu:22.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
ENV UBUNTU_FRONTEND=noninteractive
ENV HOME=/root
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
ARG NODE_DIR=${HOME}/node
ENV PATH=${NODE_DIR}/bin:${PATH}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Install pre-requisites
RUN apt-get update -qq && \
apt-get install -qq --no-install-recommends gcc g++ libgfortran5 libxml2-utils make nginx openjdk-8-jre python3 redis sqlite3 tzdata xsltproc && \
apt-get clean -qq && \
rm -rf /var/lib/apt/lists/*
# Set timezone info
RUN ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata
FROM base AS build-scilab
# Add sources and Install pre-requisites
RUN sed -i 's/^# *\(deb-src .*\.ubuntu\.com\)/\1/' /etc/apt/sources.list
# packages to be removed later
RUN apt-get update -qq && \
apt-get install -qq --no-install-recommends devscripts equivs git openjdk-8-jdk && \
mk-build-deps scilab && \
apt-get install -qq --no-install-recommends ./scilab-build-deps_*.deb && \
rm -f ./scilab-build-deps_*
# Build scilab
ARG BRANCH=master-2023.1
ARG SCILAB_DIR=${HOME}/scilab_for_xcos_on_cloud
WORKDIR ${HOME}
ADD https://api.github.com/repos/FOSSEE/scilab_for_xcos_on_cloud/git/ref/heads/${BRANCH} scilab_for_xcos_on_cloud.json
RUN git clone -q -b ${BRANCH} --depth 1 https://github.com/FOSSEE/scilab_for_xcos_on_cloud
WORKDIR ${SCILAB_DIR}
RUN ./configure --disable-dependency-tracking --disable-build-help --disable-static-system-lib --without-tk
RUN make -j4 -s V=0 || make
RUN make -s V=0 install-strip
# Cleanup
RUN apt-get autoremove -qq --purge devscripts equivs git openjdk-8-jdk openjdk-11-jre-headless scilab-build-deps '^(bsd(main|extra)utils|file|libglib2.0-data|xz-utils)$'
# Fix path in xml file
RUN sed -i "s,/usr/share/java/,${SCILAB_DIR}/thirdparty/," /usr/local/share/scilab/etc/classpath.xml
# Copy missing libs
WORKDIR ${SCILAB_DIR}
ARG LIBDIR=/usr/lib/x86_64-linux-gnu
ARG ALTLIBDIR=${HOME}/_usr_lib_x86_64-linux-gnu
RUN mkdir -p ${ALTLIBDIR}
RUN find lib/thirdparty/ usr/lib/ -name \*.so -o -name \*.so.\* | \
sort | \
while read -r f; do \
g="${f##*/}"; \
test -e ${LIBDIR}/"$g" || { cp -a "$f" ${LIBDIR}/"$g"; cp -a "$f" ${ALTLIBDIR}/"$g"; }; \
done
ARG SCILABLIBDIR=/usr/local/lib/scilab
ARG MODULELIBDIR=/usr/local/share/scilab
RUN find modules -name .libs | \
sort | \
while read -r f; do \
g="${f%/.libs}"; \
test ! -e ${MODULELIBDIR}/"$g" || ln -snf ${SCILABLIBDIR} ${MODULELIBDIR}/"$g"/.libs; \
done
ARG JNILIBDIR=/usr/lib/jni
RUN mkdir -p ${JNILIBDIR}
RUN for lib in gluegen2-rt jogl_desktop jogl_mobile nativewindow_awt nativewindow_x11 newt; do \
g=lib"$lib".so; \
f=lib/thirdparty/"$g"; \
cp -a -f "$f" ${JNILIBDIR}/"$g"; \
done
RUN rm -rf .git* modules thirdparty/docbook
RUN find ! -type d ! -name \*.jar -print0 | xargs -0 rm -f
RUN find . -mindepth 1 -type d -empty -print0 | xargs -0 rmdir -p 2> /dev/null || :
# Cleanup
RUN find /usr/local/share/scilab -depth -type d \( -name demos -o -name examples -o -name tests \) -print0 | \
xargs -0 rm -rf
RUN find /usr/local/share/locale -mindepth 1 -maxdepth 1 -type d -name \*_\* ! -name en_US -print0 | xargs -r0 rm -rf
RUN apt-get clean -qq
RUN rm -rf /var/lib/apt/lists/*
RUN rm -f /etc/{passwd,shadow,group,gshadow}-
# Comparison
#RUN dpkg-query -Wf '${Installed-Size}\t${Package}\t${Version}\n' > /tmp/dpkg-scilab
#RUN find / -mount \( -path /tmp -o -path ${ALTLIBDIR} \) -prune -o ! -type d -print | sort > /tmp/filelist-scilab
FROM base AS build-xcos
# packages to be removed later
RUN apt-get update -qq && \
apt-get install -qq --no-install-recommends gawk python3-pip python3-venv wget xz-utils
ARG NODE_VERSION=v20.19.0
ARG NODE=node-${NODE_VERSION}-linux-x64
WORKDIR ${HOME}
RUN wget -q --no-hsts https://nodejs.org/download/release/${NODE_VERSION}/${NODE}.tar.xz && \
mkdir -p ${NODE_DIR} && \
tar xf ${NODE}.tar.xz -C ${NODE_DIR} --strip-components=1 && \
rm -f ${NODE}.tar.xz
# Build XCos
ARG XCOS_DIR=${HOME}/xcosblocks
WORKDIR ${XCOS_DIR}
COPY . .
# Configure venv and sqlite3
RUN ./install.sh
# For localhost only
RUN echo 'WDS_SOCKET_PORT=80' > eda-frontend/.env.local
# Cleanup
RUN apt-get autoremove -qq --purge gawk python3-pip python3-venv wget xz-utils
RUN apt-get clean -qq
RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf ${HOME}/.cache
RUN rm -rf ${HOME}/.npm
# Comparison
#RUN dpkg-query -Wf '${Installed-Size}\t${Package}\t${Version}\n' > /tmp/dpkg-xcos
#RUN find / -mount \( -path /tmp \) -prune -o ! -type d -print | sort > /tmp/filelist-xcos
FROM base AS main
EXPOSE 80
# Install scilab
COPY --from=build-scilab /usr/local /usr/local
ARG LIBDIR=/usr/lib/x86_64-linux-gnu
ARG ALTLIBDIR=${HOME}/_usr_lib_x86_64-linux-gnu
COPY --from=build-scilab ${ALTLIBDIR} ${LIBDIR}
ARG JNILIBDIR=/usr/lib/jni
COPY --from=build-scilab ${JNILIBDIR} ${JNILIBDIR}
ARG SCILAB_DIR=${HOME}/scilab_for_xcos_on_cloud
COPY --from=build-scilab ${SCILAB_DIR} ${SCILAB_DIR}
COPY --from=build-scilab ${SCILAB_DIR}.json ${SCILAB_DIR}.json
# Install Node
COPY --from=build-xcos ${NODE_DIR} ${NODE_DIR}
# Install XCos
ARG XCOS_DIR=${HOME}/xcosblocks
COPY --from=build-xcos ${XCOS_DIR} ${XCOS_DIR}
# Install nginx
COPY --from=build-xcos /etc/nginx/sites-enabled/default /etc/nginx/sites-enabled/default
# Comparison
#COPY --from=build-scilab /tmp/dpkg-scilab /tmp/dpkg-scilab
#COPY --from=build-xcos /tmp/dpkg-xcos /tmp/dpkg-xcos
#RUN dpkg-query -Wf '${Installed-Size}\t${Package}\t${Version}\n' | sort > /tmp/dpkg-main
#RUN sort -u /tmp/dpkg-scilab /tmp/dpkg-xcos | diff /tmp/dpkg-main -
#COPY --from=build-scilab /tmp/filelist-scilab /tmp/filelist-scilab
#COPY --from=build-xcos /tmp/filelist-xcos /tmp/filelist-xcos
#RUN find / -mount \( -path /tmp \) -prune -o ! -type d -print | sort > /tmp/filelist-main
#RUN sort -u /tmp/filelist-scilab /tmp/filelist-xcos | diff /tmp/filelist-main -
WORKDIR ${XCOS_DIR}
CMD ["./run.sh"]
|