├── patches ├── adapter.cpp.patch └── cmakelists.txt.patch ├── LICENSE ├── README.md └── Dockerfile /patches/adapter.cpp.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Code/PgSQL/rdkit/adapter.cpp b/Code/PgSQL/rdkit/adapter.cpp 2 | index aab0284e..6cba4742 100644 3 | --- a/Code/PgSQL/rdkit/adapter.cpp 4 | +++ b/Code/PgSQL/rdkit/adapter.cpp 5 | @@ -63,10 +63,10 @@ 6 | #include 7 | 8 | #ifdef RDK_BUILD_INCHI_SUPPORT 9 | -#include 10 | +#include 11 | #endif 12 | #ifdef RDK_BUILD_AVALON_SUPPORT 13 | -#include 14 | +#include 15 | #endif 16 | #include 17 | #include 18 | -------------------------------------------------------------------------------- /patches/cmakelists.txt.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Code/PgSQL/rdkit/CMakeLists.txt b/Code/PgSQL/rdkit/CMakeLists.txt 2 | index fb062165..67494f8e 100644 3 | --- a/Code/PgSQL/rdkit/CMakeLists.txt 4 | +++ b/Code/PgSQL/rdkit/CMakeLists.txt 5 | @@ -1,5 +1,17 @@ 6 | cmake_minimum_required(VERSION 2.8.8) 7 | 8 | +project(RDKitPostgreSQL) 9 | +enable_testing() 10 | + 11 | +find_package(RDKit REQUIRED) 12 | +include_directories(${RDKit_INCLUDE_DIRS}) 13 | + 14 | +find_package(PostgreSQL REQUIRED) 15 | +find_package(Boost 1.39.0 REQUIRED COMPONENTS serialization) 16 | +find_package(Cairo REQUIRED) 17 | +find_package(Eigen3 REQUIRED) 18 | +find_package(Threads REQUIRED) 19 | + 20 | if(APPLE) 21 | set (EXTENSION_PREFIX "") 22 | set (EXTENSION_SUFFIX ".so") 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright 2018 Matt Swain 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PostgreSQL Docker Image with RDKit Cartridge 2 | 3 | This is a PostgreSQL Docker image with the RDKit cartridge installed. 4 | 5 | This image inherits from the [official postgres image](https://hub.docker.com/_/postgres/), and therefore has all the same environment variables for configuration, and can be extended by adding entrypoint scripts to the `/docker-entrypoint-initdb.d` directory to be run on first launch. 6 | 7 | ## Running 8 | 9 | Start Postgres server running in the background: 10 | 11 | docker run --name mypostgres -p 5432:5432 -e POSTGRES_PASSWORD=mypassword -d mcs07/postgres-rdkit 12 | 13 | Or run with an application via Docker Compose: 14 | 15 | ```yaml 16 | services: 17 | 18 | db: 19 | image: mcs07/postgres-rdkit 20 | restart: always 21 | environment: 22 | POSTGRES_PASSWORD: mypassword 23 | volumes: 24 | - /path/to/pgdata:/var/lib/postgresql/data 25 | 26 | adminer: 27 | image: adminer 28 | restart: always 29 | ports: 30 | - 8080:8080 31 | ``` 32 | 33 | This image exposes port 5432 (the postgres port), so standard container linking will make it automatically available to the linked containers. 34 | 35 | ## Environment Variables 36 | 37 | - `POSTGRES_PASSWORD`: Superuser password for PostgreSQL. 38 | - `POSTGRES_USER`: Superuser username (default `postgres`). 39 | - `POSTGRES_DB`: Default database that is created when the image is first started. 40 | - `PGDATA`: Location for the database files (default `/var/lib/postgresql/data`). 41 | 42 | See the [official postgres image](https://hub.docker.com/_/postgres/) for more details. 43 | 44 | ## Building 45 | 46 | A multi-stage docker build is used to produce a lightweight production image without all the build dependencies. This image uses [mcs07/rdkit](https://github.com/mcs07/docker-rdkit) as an earlier build stage to provide the RDKit libraries. 47 | 48 | To build, run: 49 | 50 | docker build -t postgres-rdkit . 51 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcs07/rdkit:2020.03.2 as rdkit-env 2 | 3 | FROM postgres:12 AS rdkit-postgres-build-env 4 | 5 | RUN apt-get update \ 6 | && apt-get install -yq --no-install-recommends \ 7 | ca-certificates \ 8 | build-essential \ 9 | cmake \ 10 | wget \ 11 | libboost-dev \ 12 | libboost-iostreams-dev \ 13 | libboost-python-dev \ 14 | libboost-regex-dev \ 15 | libboost-serialization-dev \ 16 | libboost-system-dev \ 17 | libboost-thread-dev \ 18 | libcairo2-dev \ 19 | libeigen3-dev \ 20 | python3-dev \ 21 | python3-numpy \ 22 | patch \ 23 | postgresql-server-dev-12 \ 24 | && apt-get clean \ 25 | && rm -rf /var/lib/apt/lists/* 26 | 27 | # Copy rdkit installation from rdkit-env 28 | COPY --from=rdkit-env /usr/lib/libRDKit* /usr/lib/ 29 | COPY --from=rdkit-env /usr/lib/cmake/rdkit/* /usr/lib/cmake/rdkit/ 30 | COPY --from=rdkit-env /usr/share/RDKit /usr/share/RDKit 31 | COPY --from=rdkit-env /usr/include/rdkit /usr/include/rdkit 32 | COPY --from=rdkit-env /usr/lib/python3/dist-packages/rdkit /usr/lib/python3/dist-packages/rdkit 33 | 34 | 35 | ARG RDKIT_VERSION=Release_2020_03_2 36 | RUN wget --quiet https://github.com/rdkit/rdkit/archive/${RDKIT_VERSION}.tar.gz \ 37 | && tar -xzf ${RDKIT_VERSION}.tar.gz \ 38 | && mv rdkit-${RDKIT_VERSION} rdkit \ 39 | && rm ${RDKIT_VERSION}.tar.gz 40 | 41 | WORKDIR /rdkit/Code/PgSQL/rdkit 42 | 43 | COPY patches/*.patch /tmp/ 44 | RUN patch CMakeLists.txt /tmp/cmakelists.txt.patch \ 45 | && patch adapter.cpp /tmp/adapter.cpp.patch 46 | 47 | RUN cmake -Wno-dev \ 48 | -D CMAKE_BUILD_TYPE=Release \ 49 | -D CMAKE_SYSTEM_PREFIX_PATH=/usr \ 50 | -D CMAKE_INSTALL_PREFIX=/usr \ 51 | -D CMAKE_MODULE_PATH=/rdkit/Code/cmake/Modules \ 52 | -D RDK_BUILD_AVALON_SUPPORT=ON \ 53 | -D RDK_BUILD_INCHI_SUPPORT=ON \ 54 | -D RDKit_DIR=/usr/lib \ 55 | -D PostgreSQL_ROOT=/usr \ 56 | -D PostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/12/server/ \ 57 | . 58 | 59 | RUN make -j $(nproc) 60 | 61 | FROM postgres:12 AS rdkit-postgres-env 62 | 63 | # Install runtime dependencies 64 | RUN apt-get update \ 65 | && apt-get install -yq --no-install-recommends \ 66 | libboost-atomic1.67.0 \ 67 | libboost-chrono1.67.0 \ 68 | libboost-date-time1.67.0 \ 69 | libboost-iostreams1.67.0 \ 70 | libboost-python1.67.0 \ 71 | libboost-regex1.67.0 \ 72 | libboost-serialization1.67.0 \ 73 | libboost-system1.67.0 \ 74 | libboost-thread1.67.0 \ 75 | libcairo2-dev \ 76 | python3-dev \ 77 | python3-numpy \ 78 | python3-cairo \ 79 | && apt-get clean \ 80 | && rm -rf /var/lib/apt/lists/* 81 | 82 | # Copy rdkit installation from rdkit-build-env 83 | COPY --from=rdkit-env /usr/lib/libRDKit* /usr/lib/ 84 | COPY --from=rdkit-env /usr/lib/cmake/rdkit /usr/lib/cmake/rdkit 85 | COPY --from=rdkit-env /usr/share/RDKit /usr/share/RDKit 86 | COPY --from=rdkit-env /usr/include/rdkit /usr/include/rdkit 87 | COPY --from=rdkit-env /usr/lib/python3/dist-packages/rdkit /usr/lib/python3/dist-packages/rdkit 88 | 89 | # Copy rdkit postgres extension from rdkit-postgres-build-env 90 | COPY --from=rdkit-postgres-build-env /rdkit/Code/PgSQL/rdkit/rdkit--3.8.sql /usr/share/postgresql/12/extension 91 | COPY --from=rdkit-postgres-build-env /rdkit/Code/PgSQL/rdkit/rdkit.control /usr/share/postgresql/12/extension 92 | COPY --from=rdkit-postgres-build-env /rdkit/Code/PgSQL/rdkit/librdkit.so /usr/lib/postgresql/12/lib/rdkit.so 93 | --------------------------------------------------------------------------------