-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile-debian
318 lines (260 loc) · 9.58 KB
/
Dockerfile-debian
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
# Multi-stage Dockerfile for building RDKit artifacts.
# The build image is a heavyweight image containing all aspects of RDKit plus the build system.
# It's artifacts are then used in the subsequent images to create lightweight images.
################################# base image ########################################
# This image contains the artifacts used by the later stages.
# The image is NOT pushed, just the cached layers used.
# also change the base image in the other sections
FROM debian:trixie as build
LABEL maintainer="Tim Dudgeon<tdudgeon@informaticsmatters.com>"
ARG GIT_REPO=https://github.com/rdkit/rdkit.git
ARG GIT_BRANCH=master
ARG GIT_TAG
# also change the POSTGRES_VER variable in the cartridge image section
ARG POSTGRES_VER=17
# also change the BOOST_VER variable in the other sections
ARG BOOST_VER=1.83
# also change the JAVA_VER variable in the java image section
ARG JAVA_VER=17
RUN apt-get update &&\
apt-get install -y --no-install-recommends \
build-essential\
python3-dev\
python3-numpy\
python3-pip\
cmake\
sqlite3\
libsqlite3-dev\
libboost$BOOST_VER\
libboost$BOOST_VER-dev\
libboost-system$BOOST_VER\
libboost-thread$BOOST_VER\
libboost-serialization$BOOST_VER\
libboost-python$BOOST_VER\
libboost-regex$BOOST_VER\
libboost-iostreams$BOOST_VER\
zlib1g-dev\
swig\
libeigen3-dev\
git\
wget\
openjdk-$JAVA_VER-jdk\
postgresql-$POSTGRES_VER\
postgresql-server-dev-$POSTGRES_VER\
postgresql-plpython3-$POSTGRES_VER\
zip\
unzip\
libfreetype6-dev &&\
apt-get clean -y
RUN if [ $GIT_TAG ]; then echo "Checking out tag $GIT_TAG from repo $GIT_REPO branch $GIT_BRANCH"; else echo "Checking out repo $GIT_REPO branch $GIT_BRANCH"; fi
RUN git clone -b $GIT_BRANCH --single-branch $GIT_REPO &&\
if [ $GIT_TAG ]; then cd rdkit && git fetch --tags && git checkout $GIT_TAG; fi
ENV RDBASE=/rdkit
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$RDBASE/lib:$RDBASE/Code/JavaWrappers/gmwrapper:/usr/lib/x86_64-linux-gnu:/usr/lib/aarch64-linux-gnu/
ENV PYTHONPATH=$PYTHONPATH:$RDBASE
RUN ln -s $(ls -d /usr/lib/jvm/java-$JAVA_VER-openjdk-*) /usr/lib/jvm/java-$JAVA_VER-openjdk
ENV JAVA_HOME=/usr/lib/jvm/java-$JAVA_VER-openjdk
ENV CLASSPATH=$RDBASE/Code/JavaWrappers/gmwrapper/org.RDKit.jar
RUN mkdir $RDBASE/build
WORKDIR $RDBASE/build
RUN cmake -Wno-dev\
-DPYTHON_EXECUTABLE=/usr/bin/python3\
-DRDK_INSTALL_INTREE=OFF\
-DRDK_BUILD_INCHI_SUPPORT=ON\
-DRDK_BUILD_AVALON_SUPPORT=ON\
-DRDK_BUILD_PYTHON_WRAPPERS=ON\
-DRDK_BUILD_SWIG_WRAPPERS=ON\
-DRDK_BUILD_PGSQL=ON\
-DPostgreSQL_ROOT=/usr/lib/postgresql/$POSTGRES_VER\
-DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/$POSTGRES_VER/server\
-DCMAKE_INSTALL_PREFIX=/usr\
-DCPACK_PACKAGE_RELOCATABLE=OFF\
..
RUN nproc=$(getconf _NPROCESSORS_ONLN)\
&& make -j $(( nproc > 2 ? nproc - 2 : 1 ))
RUN make install
RUN sh Code/PgSQL/rdkit/pgsql_install.sh
RUN cpack -G DEB
RUN cd /rdkit/Code/JavaWrappers/gmwrapper && tar cvfz javadoc.tgz doc
WORKDIR $RDBASE
################################# Python image ######################################
FROM debian:trixie AS python
LABEL maintainer="Tim Dudgeon<tdudgeon@informaticsmatters.com>"
ARG BOOST_VER=1.83
RUN apt-get update &&\
apt-get upgrade -y &&\
apt-get install -y --no-install-recommends\
python3\
python3-dev\
python3-numpy\
python3-pip\
python3-setuptools\
python3-wheel\
python3-six\
python-is-python3\
gcc\
libboost-system$BOOST_VER\
libboost-thread$BOOST_VER\
libboost-serialization$BOOST_VER\
libboost-python$BOOST_VER\
libboost-regex$BOOST_VER\
libboost-chrono$BOOST_VER\
libboost-date-time$BOOST_VER\
libboost-atomic$BOOST_VER\
libboost-iostreams$BOOST_VER\
sqlite3\
wget\
zip\
libfreetype6 &&\
apt-get clean -y
COPY --from=build /rdkit/build/RDKit-*Linux-Runtime.deb /rdkit/build/RDKit-*Linux-Python.deb /tmp/
RUN dpkg -i /tmp/RDKit-*.deb && rm -f /tmp/*.deb
ENV RDBASE=/usr/share/RDKit
# since the 2023 builds cpack seems to putting things under site-packages rather than dist-packages
ENV PYTHONPATH=/usr/lib/python3.11/site-packages
WORKDIR /
# add the rdkit user
RUN useradd -u 1000 -g 0 -m rdkit
USER 1000
################################# Java image ########################################
# Dockerfile for Java based RDKit implementation
# Based on Debian.
FROM debian:trixie AS java
LABEL maintainer="Tim Dudgeon<tdudgeon@informaticsmatters.com>"
ARG BOOST_VER=1.83
ARG JAVA_VER=17
RUN apt-get update &&\
apt-get upgrade -y &&\
apt-get install -y --no-install-recommends\
openjdk-$JAVA_VER-jre-headless\
libboost$BOOST_VER\
libboost$BOOST_VER-dev\
libboost-system$BOOST_VER\
libboost-thread$BOOST_VER\
libboost-serialization$BOOST_VER\
libboost-regex$BOOST_VER\
libboost-chrono$BOOST_VER\
libboost-date-time$BOOST_VER\
libboost-atomic$BOOST_VER\
libboost-iostreams$BOOST_VER\
libfreetype6 &&\
apt-get clean -y
COPY --from=build /rdkit/Code/JavaWrappers/gmwrapper/org.RDKit.jar /rdkit/Code/JavaWrappers/gmwrapper/libGraphMolWrap.so /rdkit/gmwrapper/
COPY --from=build /rdkit/build/RDKit-*-Linux-Runtime.deb /tmp/
RUN dpkg -i /tmp/*.deb && rm -f /tmp/*.deb
WORKDIR /
RUN ln -s $(ls -d /usr/lib/jvm/java-$JAVA_VER-openjdk-*) /usr/lib/jvm/java-$JAVA_VER-openjdk
ENV JAVA_HOME=/usr/lib/jvm/java-$JAVA_VER-openjdk
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/rdkit/gmwrapper
ENV CLASSPATH=/rdkit/gmwrapper/org.RDKit.jar
ENV RDBASE=/usr/share/RDKit
# add the rdkit user
RUN useradd -u 1000 -U -G 0 -m rdkit
USER 1000
################################# Tomcat image ######################################
FROM debian:trixie AS tomcat
LABEL maintainer="Tim Dudgeon<tdudgeon@informaticsmatters.com>"
ARG BOOST_VER=1.83
ENV TOMCAT_MAJOR 10
ENV TOMCAT_VERSION 10.1.33
ENV ARCHIVE apache-tomcat-$TOMCAT_VERSION.tar.gz
ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64
USER root
RUN apt-get update &&\
apt-get upgrade -y &&\
apt-get install -y --no-install-recommends\
openjdk-17-jre-headless\
curl\
unzip\
libboost-system$BOOST_VER\
libboost-thread$BOOST_VER\
libboost-serialization$BOOST_VER\
libboost-regex$BOOST_VER\
libboost-chrono$BOOST_VER\
libboost-date-time$BOOST_VER\
libboost-atomic$BOOST_VER\
libboost-iostreams$BOOST_VER\
libfreetype6-dev &&\
apt-get clean -y
COPY --from=build /rdkit/Code/JavaWrappers/gmwrapper/org.RDKit.jar /rdkit/Code/JavaWrappers/gmwrapper/libGraphMolWrap.so /rdkit/gmwrapper/
COPY --from=build /rdkit/build/RDKit-*-Linux-Runtime.deb /tmp/
RUN dpkg -i /tmp/*.deb && rm -f /tmp/*.deb
RUN useradd -u 501 -U -G 0 -m tomcat
WORKDIR /usr/local
RUN curl -s -o tomcat.tar.gz -L https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/$ARCHIVE &&\
tar xfz tomcat.tar.gz &&\
rm tomcat.tar.gz &&\
mv apache-tomcat-$TOMCAT_VERSION tomcat &&\
rm tomcat/bin/*.bat &&\
rm -rf tomcat/webapps/* &&\
chown -R 501:0 tomcat &&\
chmod -R g+r tomcat &&\
chmod g+w tomcat tomcat/logs tomcat/webapps tomcat/temp tomcat/work tomcat/conf tomcat/bin tomcat/lib
WORKDIR /usr/local/tomcat
ENV CATALINA_HOME /usr/local/tomcat
EXPOSE 8080
USER 501
WORKDIR $CATALINA_HOME
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/rdkit/gmwrapper
ENV CLASSPATH=/rdkit/gmwrapper/org.RDKit.jar
ENV RDBASE=/usr/share/RDKit/
RUN echo "CLASSPATH=/rdkit/gmwrapper/org.RDKit.jar\n" > /usr/local/tomcat/bin/setenv.sh
CMD ["$CATALINA_HOME/bin/catalina.sh", "run"]
################################# Cartridge image ###################################
# Dockerfile for RDKit cartridge based on Debian.
# This image is inspired by the docker.io:/library/postgres image, and uses the docker-entrypoint.sh
# file from there, but there is a need to have the exact same versions of libraries that were used to
# build the deb packages so we need to install the packages using apt to have tight control over this.
#
FROM debian:trixie AS cartridge
LABEL maintainer="Tim Dudgeon<tdudgeon@informaticsmatters.com>"
ENV POSTGRES_VER=17
ENV BOOST_VER=1.83
RUN apt-get update &&\
apt-get upgrade -y &&\
apt-get install -y --no-install-recommends\
python3\
python3-numpy\
python-is-python3\
libboost-system$BOOST_VER\
libboost-thread$BOOST_VER\
libboost-serialization$BOOST_VER\
libboost-python$BOOST_VER\
libboost-regex$BOOST_VER\
libboost-chrono$BOOST_VER\
libboost-date-time$BOOST_VER\
libboost-atomic$BOOST_VER\
libboost-iostreams$BOOST_VER\
libfreetype6\
postgresql-$POSTGRES_VER\
postgresql-client-$POSTGRES_VER\
postgresql-plpython3-$POSTGRES_VER\
pgtop\
gosu\
wget\
zip &&\
apt-get clean -y
COPY --from=build \
/rdkit/build/RDKit-*Linux-Runtime.deb \
/rdkit/build/RDKit-*Linux-Python.deb \
/rdkit/build/RDKit-*-Linux-PgSQL.deb \
/tmp/
RUN dpkg -i /tmp/RDKit-*.deb && rm -f /tmp/*.deb
WORKDIR /
# make the sample config easier to munge (and "correct by default")
RUN mv -v "/usr/share/postgresql/$POSTGRES_VER/postgresql.conf.sample" /usr/share/postgresql/ \
&& ln -sv ../postgresql.conf.sample "/usr/share/postgresql/$POSTGRES_VER/" \
&& sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/share/postgresql/postgresql.conf.sample
RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
ENV RDBASE=/usr/share/RDKit
ENV PGDATA /var/lib/postgresql/data
ENV PATH $PATH:/usr/lib/postgresql/$POSTGRES_VER/bin
# this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA"
VOLUME /var/lib/postgresql/data
ENV PYTHONPATH=/usr/lib/python3.11/site-packages
COPY docker-entrypoint-cartridge.sh /usr/local/bin/docker-entrypoint.sh
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 5432
CMD ["postgres"]