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
|
# Note: there are docker-compose .yml files that handle the 3
# build steps automatically for you; see the comments in the
# respective docker-compose files for details.
# However, if you prefer to run individual docker commands rather
# than using docker-compose, you can do so by following the
# instructions below.
#
# Example usage of this Dockerfile:
# (the --build-arg arguments are all optional)
#
# 1. cd to Code/MinimalLib/docker
# cd Code/MinimalLib/docker
#
# 2. build the MinimalLib rdkit-minimallib-deps image:
# docker build --target deps-stage -t rdkit-minimallib-deps \
# --build-arg http_proxy=$HTTP_PROXY \
# --build-arg https_proxy=$HTTP_PROXY \
# --network=host --build-arg "EXCEPTION_HANDLING=-fwasm-exceptions" \
# -f Dockerfile_1_deps .
#
# 3. build the MinimalLib rdkit-minimallib-rdkit-src image:
# 3a. from a git clone:
# docker build --target clone-stage -t rdkit-minimallib-rdkit-src \
# --build-arg http_proxy=$HTTP_PROXY \
# --build-arg https_proxy=$HTTP_PROXY \
# --build-arg "RDKIT_GIT_URL=https://github.com/myfork/rdkit.git" \
# --build-arg "RDKIT_BRANCH=mybranch" \
# --network=host -f Dockerfile_rdkit_clone_from_github .
# or
# 3b. from an existing local source tree:
# docker build --target local-src-stage -t rdkit-minimallib-rdkit-src \
# --build-arg http_proxy=$HTTP_PROXY \
# --build-arg https_proxy=$HTTP_PROXY \
# --network=host -f Dockerfile_2_rdkit_copy_from_local ../../..
#
# 4. build the MinimalLib rdkit-minimallib image:
# (the build-arg arguments are all optional; in the following
# example we select the more performant, though still experimental,
# native WASM exception handling):
# docker build -t rdkit-minimallib --network=host \
# --build-arg http_proxy=$HTTP_PROXY \
# --build-arg https_proxy=$HTTP_PROXY \
# --build-arg "EXCEPTION_HANDLING=-fwasm-exceptions" \
# -f Dockerfile_3_rdkit_build .
#
# 5. create a temporary container and copy built libraries
# from the container to your local filesystem, then destroy
# the temporary container
# docker create --name=rdkit-minimallib-container rdkit-minimallib:latest --entrypoint /
# docker cp rdkit-minimallib-container:/RDKit_minimal.js ../demo
# docker cp rdkit-minimallib-container:/RDKit_minimal.wasm ../demo
# docker rm rdkit-minimallib-container
ARG EXCEPTION_HANDLING="-fexceptions -sNO_DISABLE_EXCEPTION_CATCHING"
FROM rdkit-minimallib-rdkit-src AS build-stage
ARG EXCEPTION_HANDLING
LABEL maintainer="Greg Landrum <greg.landrum@t5informatics.com>"
WORKDIR /src
ENV RDBASE=/src/rdkit
RUN mkdir build
WORKDIR $RDBASE/build
RUN emcmake cmake -DRDK_BUILD_FREETYPE_SUPPORT=ON -DRDK_BUILD_MINIMAL_LIB=ON \
-DRDK_BUILD_PYTHON_WRAPPERS=OFF -DRDK_BUILD_CPP_TESTS=OFF -DRDK_BUILD_INCHI_SUPPORT=ON \
-DRDK_USE_BOOST_SERIALIZATION=OFF -DRDK_OPTIMIZE_POPCNT=OFF -DRDK_BUILD_THREADSAFE_SSS=OFF \
-DRDK_BUILD_DESCRIPTORS3D=OFF -DRDK_TEST_MULTITHREADED=OFF \
-DRDK_BUILD_MAEPARSER_SUPPORT=OFF -DRDK_BUILD_COORDGEN_SUPPORT=ON \
-DBoost_DIR=/opt/boost/lib/cmake/Boost-${BOOST_DOT_VERSION} \
-Dboost_headers_DIR=/opt/boost/lib/cmake/boost_headers-${BOOST_DOT_VERSION} \
-DRDK_BUILD_SLN_SUPPORT=OFF -DRDK_USE_BOOST_IOSTREAMS=OFF \
-DFREETYPE_INCLUDE_DIRS=/opt/freetype/include/freetype2 \
-DFREETYPE_LIBRARY=/opt/freetype/lib/libfreetype.a \
-DZLIB_INCLUDE_DIR=/opt/zlib/include \
-DZLIB_LIBRARY=/opt/zlib/lib/libz.a \
-DCMAKE_CXX_FLAGS="${EXCEPTION_HANDLING} -O3 -DNDEBUG" \
-DCMAKE_C_FLAGS="${EXCEPTION_HANDLING} -O3 -DNDEBUG -DCOMPILE_ANSI_ONLY" \
-DCMAKE_EXE_LINKER_FLAGS="${EXCEPTION_HANDLING} -s STACK_OVERFLOW_CHECK=1 -s USE_PTHREADS=0 -s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=4GB -s MODULARIZE=1 -s EXPORT_NAME=\"'initRDKitModule'\"" ..
# "patch" to make the InChI code work with emscripten:
RUN cp /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c.bak && \
sed 's/&& defined(__APPLE__)//' /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c.bak > /src/rdkit/External/INCHI-API/src/INCHI_BASE/src/util.c
# comment out a line which causes a compilation error on some platforms
# (based on the change which has already been applied to the RapidJSON master branch, see
# https://github.com/Tencent/rapidjson/blob/ab1842a2dae061284c0a62dca1cc6d5e7e37e346/include/rapidjson/document.h#L414)
RUN sed -i 's|^\( *\)\(GenericStringRef\& operator=(const GenericStringRef\& rhs) { s = rhs.s; length = rhs.length; } *\)$|\1//\2|' \
/src/rdkit/External/rapidjson-1.1.0/include/rapidjson/document.h
# build and "install"
RUN make -j2 RDKit_minimal && \
cp Code/MinimalLib/RDKit_minimal.* ../Code/MinimalLib/demo/
# run the tests
WORKDIR /src/rdkit/Code/MinimalLib/tests
RUN /opt/emsdk/node/*/bin/node tests.js
# Copy js and wasm rdkit files to use in browser
# This feature requires the BuildKit backend
# https://docs.docker.com/engine/reference/commandline/build/#custom-build-outputs
FROM scratch as export-stage
COPY --from=build-stage /src/rdkit/Code/MinimalLib/demo /
COPY --from=build-stage /src/rdkit/Code/MinimalLib/docs /
|