mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-07 05:22:56 +00:00
Upgrade pgvector to 0.7.0. This PR is based on Heikki's PR #6753 and just uses pgvector 0.7.0 instead of 0.6.0 I have now done all planned manual tests. The pull request is ready to be reviewed and merged and can be deployed in production together / after swap enablement. See (https://github.com/neondatabase/autoscaling/issues/800) Fixes https://github.com/neondatabase/neon/issues/6516 Fixes https://github.com/neondatabase/neon/issues/7780 ## Documentation input for usage recommendations ### maintenance_work_mem In Neon `maintenance_work_mem` is very small by default (depends on configured RAM for your compute but can be as low as 64 MB). To optimize pgvector index build time you may have to bump it up according to your working set size (size of tuples for vector index creation). You can do so in the current session using `SET maintenance_work_mem='10 GB';` The target value you choose should fit into the memory of your compute size and not exceed 50-60% of available RAM. The value above has been successfully used on a 7CU endpoint. ### max_parallel_maintenance_workers max_parallel_maintenance_workers is also small by default (2). For efficient parallel pgvector index creation you have to bump it up with `SET max_parallel_maintenance_workers = 7` to make use of all the CPUs available, assuming you have configured your endpoint to use 7CU. ## ID input for changelog pgvector extension in Neon has been upgraded from version 0.5.1 to version 0.7.0. Please see https://github.com/pgvector/pgvector/ for documentation of new capabilities in pgvector version 0.7.0 If you have existing databases with pgvector 0.5.1 already installed there is a slight difference in behavior in the following corner cases even if you don't run `ALTER EXTENSION UPDATE`: ### L2 distance from NULL::vector For the following script, comparing the NULL::vector to non-null vectors the resulting output changes: ```sql SET enable_seqscan = off; CREATE TABLE t (val vector(3)); INSERT INTO t (val) VALUES ('[0,0,0]'), ('[1,2,3]'), ('[1,1,1]'), (NULL); CREATE INDEX ON t USING hnsw (val vector_l2_ops); INSERT INTO t (val) VALUES ('[1,2,4]'); SELECT * FROM t ORDER BY val <-> (SELECT NULL::vector); ``` and now the output is ``` val --------- [1,1,1] [1,2,4] [1,2,3] [0,0,0] (4 rows) ``` For the following script ```sql SET enable_seqscan = off; CREATE TABLE t (val vector(3)); INSERT INTO t (val) VALUES ('[0,0,0]'), ('[1,2,3]'), ('[1,1,1]'), (NULL); CREATE INDEX ON t USING ivfflat (val vector_l2_ops) WITH (lists = 1); INSERT INTO t (val) VALUES ('[1,2,4]'); SELECT * FROM t ORDER BY val <-> (SELECT NULL::vector); ``` the output now is ``` val --------- [0,0,0] [1,2,3] [1,1,1] [1,2,4] (4 rows) ``` ### changed error messages If you provide invalid literals for datatype vector you may get improved/changed error messages, for example: ```sql neondb=> SELECT '[4e38,1]'::vector; ERROR: "4e38" is out of range for type vector LINE 1: SELECT '[4e38,1]'::vector; ^ ``` --------- Co-authored-by: Heikki Linnakangas <heikki@neon.tech>
992 lines
50 KiB
Docker
992 lines
50 KiB
Docker
ARG PG_VERSION
|
|
ARG REPOSITORY=neondatabase
|
|
ARG IMAGE=build-tools
|
|
ARG TAG=pinned
|
|
ARG BUILD_TAG
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "build-deps"
|
|
#
|
|
#########################################################################################
|
|
FROM debian:bullseye-slim AS build-deps
|
|
RUN apt update && \
|
|
apt install -y git autoconf automake libtool build-essential bison flex libreadline-dev \
|
|
zlib1g-dev libxml2-dev libcurl4-openssl-dev libossp-uuid-dev wget pkg-config libssl-dev \
|
|
libicu-dev libxslt1-dev liblz4-dev libzstd-dev zstd
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-build"
|
|
# Build Postgres from the neon postgres repository.
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-build
|
|
ARG PG_VERSION
|
|
COPY vendor/postgres-${PG_VERSION} postgres
|
|
RUN cd postgres && \
|
|
export CONFIGURE_CMD="./configure CFLAGS='-O2 -g3' --enable-debug --with-openssl --with-uuid=ossp \
|
|
--with-icu --with-libxml --with-libxslt --with-lz4" && \
|
|
if [ "${PG_VERSION}" != "v14" ]; then \
|
|
# zstd is available only from PG15
|
|
export CONFIGURE_CMD="${CONFIGURE_CMD} --with-zstd"; \
|
|
fi && \
|
|
eval $CONFIGURE_CMD && \
|
|
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s install && \
|
|
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C contrib/ install && \
|
|
# Install headers
|
|
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C src/include install && \
|
|
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C src/interfaces/libpq install && \
|
|
# Enable some of contrib extensions
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/autoinc.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/bloom.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/earthdistance.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/insert_username.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/intagg.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/moddatetime.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pg_stat_statements.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgrowlocks.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgstattuple.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/refint.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/xml2.control && \
|
|
# We need to grant EXECUTE on pg_stat_statements_reset() to neon_superuser.
|
|
# In vanilla postgres this function is limited to Postgres role superuser.
|
|
# In neon we have neon_superuser role that is not a superuser but replaces superuser in some cases.
|
|
# We could add the additional grant statements to the postgres repository but it would be hard to maintain,
|
|
# whenever we need to pick up a new postgres version and we want to limit the changes in our postgres fork,
|
|
# so we do it here.
|
|
old_list="pg_stat_statements--1.0--1.1.sql pg_stat_statements--1.1--1.2.sql pg_stat_statements--1.2--1.3.sql pg_stat_statements--1.3--1.4.sql pg_stat_statements--1.4--1.5.sql pg_stat_statements--1.4.sql pg_stat_statements--1.5--1.6.sql"; \
|
|
# the first loop is for pg_stat_statement extension version <= 1.6
|
|
for file in /usr/local/pgsql/share/extension/pg_stat_statements--*.sql; do \
|
|
filename=$(basename "$file"); \
|
|
if echo "$old_list" | grep -q -F "$filename"; then \
|
|
echo 'GRANT EXECUTE ON FUNCTION pg_stat_statements_reset() TO neon_superuser;' >> $file; \
|
|
fi; \
|
|
done; \
|
|
# the second loop is for pg_stat_statement extension versions >= 1.7,
|
|
# where pg_stat_statement_reset() got 3 additional arguments
|
|
for file in /usr/local/pgsql/share/extension/pg_stat_statements--*.sql; do \
|
|
filename=$(basename "$file"); \
|
|
if ! echo "$old_list" | grep -q -F "$filename"; then \
|
|
echo 'GRANT EXECUTE ON FUNCTION pg_stat_statements_reset(Oid, Oid, bigint) TO neon_superuser;' >> $file; \
|
|
fi; \
|
|
done
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "postgis-build"
|
|
# Build PostGIS from the upstream PostGIS mirror.
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS postgis-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
RUN apt update && \
|
|
apt install -y cmake gdal-bin libboost-dev libboost-thread-dev libboost-filesystem-dev \
|
|
libboost-system-dev libboost-iostreams-dev libboost-program-options-dev libboost-timer-dev \
|
|
libcgal-dev libgdal-dev libgmp-dev libmpfr-dev libopenscenegraph-dev libprotobuf-c-dev \
|
|
protobuf-c-compiler xsltproc
|
|
|
|
# SFCGAL > 1.3 requires CGAL > 5.2, Bullseye's libcgal-dev is 5.2
|
|
RUN wget https://gitlab.com/Oslandia/SFCGAL/-/archive/v1.3.10/SFCGAL-v1.3.10.tar.gz -O SFCGAL.tar.gz && \
|
|
echo "4e39b3b2adada6254a7bdba6d297bb28e1a9835a9f879b74f37e2dab70203232 SFCGAL.tar.gz" | sha256sum --check && \
|
|
mkdir sfcgal-src && cd sfcgal-src && tar xvzf ../SFCGAL.tar.gz --strip-components=1 -C . && \
|
|
cmake -DCMAKE_BUILD_TYPE=Release . && make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
DESTDIR=/sfcgal make install -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make clean && cp -R /sfcgal/* /
|
|
|
|
ENV PATH "/usr/local/pgsql/bin:$PATH"
|
|
|
|
RUN wget https://download.osgeo.org/postgis/source/postgis-3.3.3.tar.gz -O postgis.tar.gz && \
|
|
echo "74eb356e3f85f14233791013360881b6748f78081cc688ff9d6f0f673a762d13 postgis.tar.gz" | sha256sum --check && \
|
|
mkdir postgis-src && cd postgis-src && tar xvzf ../postgis.tar.gz --strip-components=1 -C . && \
|
|
find /usr/local/pgsql -type f | sed 's|^/usr/local/pgsql/||' > /before.txt &&\
|
|
./autogen.sh && \
|
|
./configure --with-sfcgal=/usr/local/bin/sfcgal-config && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
cd extensions/postgis && \
|
|
make clean && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/postgis.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/postgis_raster.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/postgis_sfcgal.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/postgis_tiger_geocoder.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/postgis_topology.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/address_standardizer.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/address_standardizer_data_us.control && \
|
|
mkdir -p /extensions/postgis && \
|
|
cp /usr/local/pgsql/share/extension/postgis.control /extensions/postgis && \
|
|
cp /usr/local/pgsql/share/extension/postgis_raster.control /extensions/postgis && \
|
|
cp /usr/local/pgsql/share/extension/postgis_sfcgal.control /extensions/postgis && \
|
|
cp /usr/local/pgsql/share/extension/postgis_tiger_geocoder.control /extensions/postgis && \
|
|
cp /usr/local/pgsql/share/extension/postgis_topology.control /extensions/postgis && \
|
|
cp /usr/local/pgsql/share/extension/address_standardizer.control /extensions/postgis && \
|
|
cp /usr/local/pgsql/share/extension/address_standardizer_data_us.control /extensions/postgis
|
|
|
|
RUN wget https://github.com/pgRouting/pgrouting/archive/v3.4.2.tar.gz -O pgrouting.tar.gz && \
|
|
echo "cac297c07d34460887c4f3b522b35c470138760fe358e351ad1db4edb6ee306e pgrouting.tar.gz" | sha256sum --check && \
|
|
mkdir pgrouting-src && cd pgrouting-src && tar xvzf ../pgrouting.tar.gz --strip-components=1 -C . && \
|
|
mkdir build && cd build && \
|
|
cmake -DCMAKE_BUILD_TYPE=Release .. && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgrouting.control && \
|
|
find /usr/local/pgsql -type f | sed 's|^/usr/local/pgsql/||' > /after.txt &&\
|
|
cp /usr/local/pgsql/share/extension/pgrouting.control /extensions/postgis && \
|
|
sort -o /before.txt /before.txt && sort -o /after.txt /after.txt && \
|
|
comm -13 /before.txt /after.txt | tar --directory=/usr/local/pgsql --zstd -cf /extensions/postgis.tar.zst -T -
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "plv8-build"
|
|
# Build plv8
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS plv8-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN apt update && \
|
|
apt install -y ninja-build python3-dev libncurses5 binutils clang
|
|
|
|
RUN wget https://github.com/plv8/plv8/archive/refs/tags/v3.1.10.tar.gz -O plv8.tar.gz && \
|
|
echo "7096c3290928561f0d4901b7a52794295dc47f6303102fae3f8e42dd575ad97d plv8.tar.gz" | sha256sum --check && \
|
|
mkdir plv8-src && cd plv8-src && tar xvzf ../plv8.tar.gz --strip-components=1 -C . && \
|
|
# generate and copy upgrade scripts
|
|
mkdir -p upgrade && ./generate_upgrade.sh 3.1.10 && \
|
|
cp upgrade/* /usr/local/pgsql/share/extension/ && \
|
|
export PATH="/usr/local/pgsql/bin:$PATH" && \
|
|
make DOCKER=1 -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
rm -rf /plv8-* && \
|
|
find /usr/local/pgsql/ -name "plv8-*.so" | xargs strip && \
|
|
# don't break computes with installed old version of plv8
|
|
cd /usr/local/pgsql/lib/ && \
|
|
ln -s plv8-3.1.10.so plv8-3.1.5.so && \
|
|
ln -s plv8-3.1.10.so plv8-3.1.8.so && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/plv8.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/plcoffee.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/plls.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "h3-pg-build"
|
|
# Build h3_pg
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS h3-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN case "$(uname -m)" in \
|
|
"x86_64") \
|
|
export CMAKE_CHECKSUM=739d372726cb23129d57a539ce1432453448816e345e1545f6127296926b6754 \
|
|
;; \
|
|
"aarch64") \
|
|
export CMAKE_CHECKSUM=281b42627c9a1beed03e29706574d04c6c53fae4994472e90985ef018dd29c02 \
|
|
;; \
|
|
*) \
|
|
echo "Unsupported architecture '$(uname -m)'. Supported are x86_64 and aarch64" && exit 1 \
|
|
;; \
|
|
esac && \
|
|
wget https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-$(uname -m).sh \
|
|
-q -O /tmp/cmake-install.sh \
|
|
&& echo "${CMAKE_CHECKSUM} /tmp/cmake-install.sh" | sha256sum --check \
|
|
&& chmod u+x /tmp/cmake-install.sh \
|
|
&& /tmp/cmake-install.sh --skip-license --prefix=/usr/local/ \
|
|
&& rm /tmp/cmake-install.sh
|
|
|
|
RUN wget https://github.com/uber/h3/archive/refs/tags/v4.1.0.tar.gz -O h3.tar.gz && \
|
|
echo "ec99f1f5974846bde64f4513cf8d2ea1b8d172d2218ab41803bf6a63532272bc h3.tar.gz" | sha256sum --check && \
|
|
mkdir h3-src && cd h3-src && tar xvzf ../h3.tar.gz --strip-components=1 -C . && \
|
|
mkdir build && cd build && \
|
|
cmake .. -DCMAKE_BUILD_TYPE=Release && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
DESTDIR=/h3 make install && \
|
|
cp -R /h3/usr / && \
|
|
rm -rf build
|
|
|
|
RUN wget https://github.com/zachasme/h3-pg/archive/refs/tags/v4.1.3.tar.gz -O h3-pg.tar.gz && \
|
|
echo "5c17f09a820859ffe949f847bebf1be98511fb8f1bd86f94932512c00479e324 h3-pg.tar.gz" | sha256sum --check && \
|
|
mkdir h3-pg-src && cd h3-pg-src && tar xvzf ../h3-pg.tar.gz --strip-components=1 -C . && \
|
|
export PATH="/usr/local/pgsql/bin:$PATH" && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/h3.control && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/h3_postgis.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "unit-pg-build"
|
|
# compile unit extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS unit-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN wget https://github.com/df7cb/postgresql-unit/archive/refs/tags/7.7.tar.gz -O postgresql-unit.tar.gz && \
|
|
echo "411d05beeb97e5a4abf17572bfcfbb5a68d98d1018918feff995f6ee3bb03e79 postgresql-unit.tar.gz" | sha256sum --check && \
|
|
mkdir postgresql-unit-src && cd postgresql-unit-src && tar xvzf ../postgresql-unit.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
# unit extension's "create extension" script relies on absolute install path to fill some reference tables.
|
|
# We move the extension from '/usr/local/pgsql/' to '/usr/local/' after it is build. So we need to adjust the path.
|
|
# This one-liner removes pgsql/ part of the path.
|
|
# NOTE: Other extensions that rely on MODULEDIR variable after building phase will need the same fix.
|
|
find /usr/local/pgsql/share/extension/ -name "unit*.sql" -print0 | xargs -0 sed -i "s|pgsql/||g" && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/unit.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "vector-pg-build"
|
|
# compile pgvector extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS vector-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
COPY patches/pgvector.patch /pgvector.patch
|
|
|
|
RUN wget https://github.com/pgvector/pgvector/archive/refs/tags/v0.7.0.tar.gz -O pgvector.tar.gz && \
|
|
echo "1b5503a35c265408b6eb282621c5e1e75f7801afc04eecb950796cfee2e3d1d8 pgvector.tar.gz" | sha256sum --check && \
|
|
mkdir pgvector-src && cd pgvector-src && tar xvzf ../pgvector.tar.gz --strip-components=1 -C . && \
|
|
patch -p1 < /pgvector.patch && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/vector.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pgjwt-pg-build"
|
|
# compile pgjwt extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pgjwt-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
# 9742dab1b2f297ad3811120db7b21451bca2d3c9 made on 13/11/2021
|
|
RUN wget https://github.com/michelp/pgjwt/archive/9742dab1b2f297ad3811120db7b21451bca2d3c9.tar.gz -O pgjwt.tar.gz && \
|
|
echo "cfdefb15007286f67d3d45510f04a6a7a495004be5b3aecb12cda667e774203f pgjwt.tar.gz" | sha256sum --check && \
|
|
mkdir pgjwt-src && cd pgjwt-src && tar xvzf ../pgjwt.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgjwt.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "hypopg-pg-build"
|
|
# compile hypopg extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS hypopg-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN wget https://github.com/HypoPG/hypopg/archive/refs/tags/1.4.0.tar.gz -O hypopg.tar.gz && \
|
|
echo "0821011743083226fc9b813c1f2ef5897a91901b57b6bea85a78e466187c6819 hypopg.tar.gz" | sha256sum --check && \
|
|
mkdir hypopg-src && cd hypopg-src && tar xvzf ../hypopg.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/hypopg.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-hashids-pg-build"
|
|
# compile pg_hashids extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-hashids-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN wget https://github.com/iCyberon/pg_hashids/archive/refs/tags/v1.2.1.tar.gz -O pg_hashids.tar.gz && \
|
|
echo "74576b992d9277c92196dd8d816baa2cc2d8046fe102f3dcd7f3c3febed6822a pg_hashids.tar.gz" | sha256sum --check && \
|
|
mkdir pg_hashids-src && cd pg_hashids-src && tar xvzf ../pg_hashids.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config USE_PGXS=1 && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config USE_PGXS=1 && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pg_hashids.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "rum-pg-build"
|
|
# compile rum extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS rum-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN wget https://github.com/postgrespro/rum/archive/refs/tags/1.3.13.tar.gz -O rum.tar.gz && \
|
|
echo "6ab370532c965568df6210bd844ac6ba649f53055e48243525b0b7e5c4d69a7d rum.tar.gz" | sha256sum --check && \
|
|
mkdir rum-src && cd rum-src && tar xvzf ../rum.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config USE_PGXS=1 && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config USE_PGXS=1 && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/rum.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pgtap-pg-build"
|
|
# compile pgTAP extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pgtap-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN wget https://github.com/theory/pgtap/archive/refs/tags/v1.2.0.tar.gz -O pgtap.tar.gz && \
|
|
echo "9c7c3de67ea41638e14f06da5da57bac6f5bd03fea05c165a0ec862205a5c052 pgtap.tar.gz" | sha256sum --check && \
|
|
mkdir pgtap-src && cd pgtap-src && tar xvzf ../pgtap.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgtap.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "ip4r-pg-build"
|
|
# compile ip4r extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS ip4r-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN wget https://github.com/RhodiumToad/ip4r/archive/refs/tags/2.4.2.tar.gz -O ip4r.tar.gz && \
|
|
echo "0f7b1f159974f49a47842a8ab6751aecca1ed1142b6d5e38d81b064b2ead1b4b ip4r.tar.gz" | sha256sum --check && \
|
|
mkdir ip4r-src && cd ip4r-src && tar xvzf ../ip4r.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/ip4r.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "prefix-pg-build"
|
|
# compile Prefix extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS prefix-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN wget https://github.com/dimitri/prefix/archive/refs/tags/v1.2.10.tar.gz -O prefix.tar.gz && \
|
|
echo "4342f251432a5f6fb05b8597139d3ccde8dcf87e8ca1498e7ee931ca057a8575 prefix.tar.gz" | sha256sum --check && \
|
|
mkdir prefix-src && cd prefix-src && tar xvzf ../prefix.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/prefix.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "hll-pg-build"
|
|
# compile hll extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS hll-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN wget https://github.com/citusdata/postgresql-hll/archive/refs/tags/v2.18.tar.gz -O hll.tar.gz && \
|
|
echo "e2f55a6f4c4ab95ee4f1b4a2b73280258c5136b161fe9d059559556079694f0e hll.tar.gz" | sha256sum --check && \
|
|
mkdir hll-src && cd hll-src && tar xvzf ../hll.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/hll.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "plpgsql-check-pg-build"
|
|
# compile plpgsql_check extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS plpgsql-check-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN wget https://github.com/okbob/plpgsql_check/archive/refs/tags/v2.5.3.tar.gz -O plpgsql_check.tar.gz && \
|
|
echo "6631ec3e7fb3769eaaf56e3dfedb829aa761abf163d13dba354b4c218508e1c0 plpgsql_check.tar.gz" | sha256sum --check && \
|
|
mkdir plpgsql_check-src && cd plpgsql_check-src && tar xvzf ../plpgsql_check.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) PG_CONFIG=/usr/local/pgsql/bin/pg_config USE_PGXS=1 && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config USE_PGXS=1 && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/plpgsql_check.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "timescaledb-pg-build"
|
|
# compile timescaledb extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS timescaledb-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ARG PG_VERSION
|
|
ENV PATH "/usr/local/pgsql/bin:$PATH"
|
|
|
|
RUN case "${PG_VERSION}" in \
|
|
"v14" | "v15") \
|
|
export TIMESCALEDB_VERSION=2.10.1 \
|
|
export TIMESCALEDB_CHECKSUM=6fca72a6ed0f6d32d2b3523951ede73dc5f9b0077b38450a029a5f411fdb8c73 \
|
|
;; \
|
|
*) \
|
|
export TIMESCALEDB_VERSION=2.13.0 \
|
|
export TIMESCALEDB_CHECKSUM=584a351c7775f0e067eaa0e7277ea88cab9077cc4c455cbbf09a5d9723dce95d \
|
|
;; \
|
|
esac && \
|
|
apt-get update && \
|
|
apt-get install -y cmake && \
|
|
wget https://github.com/timescale/timescaledb/archive/refs/tags/${TIMESCALEDB_VERSION}.tar.gz -O timescaledb.tar.gz && \
|
|
echo "${TIMESCALEDB_CHECKSUM} timescaledb.tar.gz" | sha256sum --check && \
|
|
mkdir timescaledb-src && cd timescaledb-src && tar xvzf ../timescaledb.tar.gz --strip-components=1 -C . && \
|
|
./bootstrap -DSEND_TELEMETRY_DEFAULT:BOOL=OFF -DUSE_TELEMETRY:BOOL=OFF -DAPACHE_ONLY:BOOL=ON -DCMAKE_BUILD_TYPE=Release && \
|
|
cd build && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make install -j $(getconf _NPROCESSORS_ONLN) && \
|
|
echo "trusted = true" >> /usr/local/pgsql/share/extension/timescaledb.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-hint-plan-pg-build"
|
|
# compile pg_hint_plan extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-hint-plan-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ARG PG_VERSION
|
|
ENV PATH "/usr/local/pgsql/bin:$PATH"
|
|
|
|
RUN case "${PG_VERSION}" in \
|
|
"v14") \
|
|
export PG_HINT_PLAN_VERSION=14_1_4_1 \
|
|
export PG_HINT_PLAN_CHECKSUM=c3501becf70ead27f70626bce80ea401ceac6a77e2083ee5f3ff1f1444ec1ad1 \
|
|
;; \
|
|
"v15") \
|
|
export PG_HINT_PLAN_VERSION=15_1_5_0 \
|
|
export PG_HINT_PLAN_CHECKSUM=564cbbf4820973ffece63fbf76e3c0af62c4ab23543142c7caaa682bc48918be \
|
|
;; \
|
|
"v16") \
|
|
export PG_HINT_PLAN_VERSION=16_1_6_0 \
|
|
export PG_HINT_PLAN_CHECKSUM=fc85a9212e7d2819d4ae4ac75817481101833c3cfa9f0fe1f980984e12347d00 \
|
|
;; \
|
|
*) \
|
|
echo "Export the valid PG_HINT_PLAN_VERSION variable" && exit 1 \
|
|
;; \
|
|
esac && \
|
|
wget https://github.com/ossc-db/pg_hint_plan/archive/refs/tags/REL${PG_HINT_PLAN_VERSION}.tar.gz -O pg_hint_plan.tar.gz && \
|
|
echo "${PG_HINT_PLAN_CHECKSUM} pg_hint_plan.tar.gz" | sha256sum --check && \
|
|
mkdir pg_hint_plan-src && cd pg_hint_plan-src && tar xvzf ../pg_hint_plan.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make install -j $(getconf _NPROCESSORS_ONLN) && \
|
|
echo "trusted = true" >> /usr/local/pgsql/share/extension/pg_hint_plan.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "kq-imcx-pg-build"
|
|
# compile kq_imcx extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS kq-imcx-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN apt-get update && \
|
|
apt-get install -y git libgtk2.0-dev libpq-dev libpam-dev libxslt-dev libkrb5-dev cmake && \
|
|
wget https://github.com/ketteq-neon/postgres-exts/archive/e0bd1a9d9313d7120c1b9c7bb15c48c0dede4c4e.tar.gz -O kq_imcx.tar.gz && \
|
|
echo "dc93a97ff32d152d32737ba7e196d9687041cda15e58ab31344c2f2de8855336 kq_imcx.tar.gz" | sha256sum --check && \
|
|
mkdir kq_imcx-src && cd kq_imcx-src && tar xvzf ../kq_imcx.tar.gz --strip-components=1 -C . && \
|
|
find /usr/local/pgsql -type f | sed 's|^/usr/local/pgsql/||' > /before.txt &&\
|
|
mkdir build && cd build && \
|
|
cmake -DCMAKE_BUILD_TYPE=Release .. && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/kq_imcx.control && \
|
|
find /usr/local/pgsql -type f | sed 's|^/usr/local/pgsql/||' > /after.txt &&\
|
|
mkdir -p /extensions/kq_imcx && cp /usr/local/pgsql/share/extension/kq_imcx.control /extensions/kq_imcx && \
|
|
sort -o /before.txt /before.txt && sort -o /after.txt /after.txt && \
|
|
comm -13 /before.txt /after.txt | tar --directory=/usr/local/pgsql --zstd -cf /extensions/kq_imcx.tar.zst -T -
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-cron-pg-build"
|
|
# compile pg_cron extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-cron-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN wget https://github.com/citusdata/pg_cron/archive/refs/tags/v1.6.0.tar.gz -O pg_cron.tar.gz && \
|
|
echo "383a627867d730222c272bfd25cd5e151c578d73f696d32910c7db8c665cc7db pg_cron.tar.gz" | sha256sum --check && \
|
|
mkdir pg_cron-src && cd pg_cron-src && tar xvzf ../pg_cron.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pg_cron.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "rdkit-pg-build"
|
|
# compile rdkit extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS rdkit-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y \
|
|
cmake \
|
|
libboost-iostreams1.74-dev \
|
|
libboost-regex1.74-dev \
|
|
libboost-serialization1.74-dev \
|
|
libboost-system1.74-dev \
|
|
libeigen3-dev
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:/usr/local/pgsql/:$PATH"
|
|
RUN wget https://github.com/rdkit/rdkit/archive/refs/tags/Release_2023_03_3.tar.gz -O rdkit.tar.gz && \
|
|
echo "bdbf9a2e6988526bfeb8c56ce3cdfe2998d60ac289078e2215374288185e8c8d rdkit.tar.gz" | sha256sum --check && \
|
|
mkdir rdkit-src && cd rdkit-src && tar xvzf ../rdkit.tar.gz --strip-components=1 -C . && \
|
|
cmake \
|
|
-D RDK_BUILD_CAIRO_SUPPORT=OFF \
|
|
-D RDK_BUILD_INCHI_SUPPORT=ON \
|
|
-D RDK_BUILD_AVALON_SUPPORT=ON \
|
|
-D RDK_BUILD_PYTHON_WRAPPERS=OFF \
|
|
-D RDK_BUILD_DESCRIPTORS3D=OFF \
|
|
-D RDK_BUILD_FREESASA_SUPPORT=OFF \
|
|
-D RDK_BUILD_COORDGEN_SUPPORT=ON \
|
|
-D RDK_BUILD_MOLINTERCHANGE_SUPPORT=OFF \
|
|
-D RDK_BUILD_YAEHMOP_SUPPORT=OFF \
|
|
-D RDK_BUILD_STRUCTCHECKER_SUPPORT=OFF \
|
|
-D RDK_USE_URF=OFF \
|
|
-D RDK_BUILD_PGSQL=ON \
|
|
-D RDK_PGSQL_STATIC=ON \
|
|
-D PostgreSQL_CONFIG=pg_config \
|
|
-D PostgreSQL_INCLUDE_DIR=`pg_config --includedir` \
|
|
-D PostgreSQL_TYPE_INCLUDE_DIR=`pg_config --includedir-server` \
|
|
-D PostgreSQL_LIBRARY_DIR=`pg_config --libdir` \
|
|
-D RDK_INSTALL_INTREE=OFF \
|
|
-D RDK_INSTALL_COMIC_FONTS=OFF \
|
|
-D RDK_BUILD_FREETYPE_SUPPORT=OFF \
|
|
-D CMAKE_BUILD_TYPE=Release \
|
|
. && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/rdkit.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-uuidv7-pg-build"
|
|
# compile pg_uuidv7 extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-uuidv7-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN wget https://github.com/fboulnois/pg_uuidv7/archive/refs/tags/v1.0.1.tar.gz -O pg_uuidv7.tar.gz && \
|
|
echo "0d0759ab01b7fb23851ecffb0bce27822e1868a4a5819bfd276101c716637a7a pg_uuidv7.tar.gz" | sha256sum --check && \
|
|
mkdir pg_uuidv7-src && cd pg_uuidv7-src && tar xvzf ../pg_uuidv7.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pg_uuidv7.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-roaringbitmap-pg-build"
|
|
# compile pg_roaringbitmap extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-roaringbitmap-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN wget https://github.com/ChenHuajun/pg_roaringbitmap/archive/refs/tags/v0.5.4.tar.gz -O pg_roaringbitmap.tar.gz && \
|
|
echo "b75201efcb1c2d1b014ec4ae6a22769cc7a224e6e406a587f5784a37b6b5a2aa pg_roaringbitmap.tar.gz" | sha256sum --check && \
|
|
mkdir pg_roaringbitmap-src && cd pg_roaringbitmap-src && tar xvzf ../pg_roaringbitmap.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/roaringbitmap.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-semver-pg-build"
|
|
# compile pg_semver extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-semver-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN wget https://github.com/theory/pg-semver/archive/refs/tags/v0.32.1.tar.gz -O pg_semver.tar.gz && \
|
|
echo "fbdaf7512026d62eec03fad8687c15ed509b6ba395bff140acd63d2e4fbe25d7 pg_semver.tar.gz" | sha256sum --check && \
|
|
mkdir pg_semver-src && cd pg_semver-src && tar xvzf ../pg_semver.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/semver.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-embedding-pg-build"
|
|
# compile pg_embedding extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-embedding-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ARG PG_VERSION
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN case "${PG_VERSION}" in \
|
|
"v14" | "v15") \
|
|
export PG_EMBEDDING_VERSION=0.3.5 \
|
|
export PG_EMBEDDING_CHECKSUM=0e95b27b8b6196e2cf0a0c9ec143fe2219b82e54c5bb4ee064e76398cbe69ae9 \
|
|
;; \
|
|
*) \
|
|
echo "pg_embedding not supported on this PostgreSQL version. Use pgvector instead." && exit 0;; \
|
|
esac && \
|
|
wget https://github.com/neondatabase/pg_embedding/archive/refs/tags/${PG_EMBEDDING_VERSION}.tar.gz -O pg_embedding.tar.gz && \
|
|
echo "${PG_EMBEDDING_CHECKSUM} pg_embedding.tar.gz" | sha256sum --check && \
|
|
mkdir pg_embedding-src && cd pg_embedding-src && tar xvzf ../pg_embedding.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-anon-pg-build"
|
|
# compile anon extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-anon-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN wget https://github.com/neondatabase/postgresql_anonymizer/archive/refs/tags/neon_1.1.1.tar.gz -O pg_anon.tar.gz && \
|
|
echo "321ea8d5c1648880aafde850a2c576e4a9e7b9933a34ce272efc839328999fa9 pg_anon.tar.gz" | sha256sum --check && \
|
|
mkdir pg_anon-src && cd pg_anon-src && tar xvzf ../pg_anon.tar.gz --strip-components=1 -C . && \
|
|
find /usr/local/pgsql -type f | sed 's|^/usr/local/pgsql/||' > /before.txt &&\
|
|
make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/anon.control && \
|
|
find /usr/local/pgsql -type f | sed 's|^/usr/local/pgsql/||' > /after.txt &&\
|
|
mkdir -p /extensions/anon && cp /usr/local/pgsql/share/extension/anon.control /extensions/anon && \
|
|
sort -o /before.txt /before.txt && sort -o /after.txt /after.txt && \
|
|
comm -13 /before.txt /after.txt | tar --directory=/usr/local/pgsql --zstd -cf /extensions/anon.tar.zst -T -
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "rust extensions"
|
|
# This layer is used to build `pgrx` deps
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS rust-extensions-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y curl libclang-dev cmake && \
|
|
useradd -ms /bin/bash nonroot -b /home
|
|
|
|
ENV HOME=/home/nonroot
|
|
ENV PATH="/home/nonroot/.cargo/bin:/usr/local/pgsql/bin/:$PATH"
|
|
USER nonroot
|
|
WORKDIR /home/nonroot
|
|
ARG PG_VERSION
|
|
|
|
RUN curl -sSO https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux-gnu/rustup-init && \
|
|
chmod +x rustup-init && \
|
|
./rustup-init -y --no-modify-path --profile minimal --default-toolchain stable && \
|
|
rm rustup-init && \
|
|
cargo install --locked --version 0.10.2 cargo-pgrx && \
|
|
/bin/bash -c 'cargo pgrx init --pg${PG_VERSION:1}=/usr/local/pgsql/bin/pg_config'
|
|
|
|
USER root
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-jsonschema-pg-build"
|
|
# Compile "pg_jsonschema" extension
|
|
#
|
|
#########################################################################################
|
|
|
|
FROM rust-extensions-build AS pg-jsonschema-pg-build
|
|
ARG PG_VERSION
|
|
|
|
RUN wget https://github.com/supabase/pg_jsonschema/archive/refs/tags/v0.2.0.tar.gz -O pg_jsonschema.tar.gz && \
|
|
echo "9118fc508a6e231e7a39acaa6f066fcd79af17a5db757b47d2eefbe14f7794f0 pg_jsonschema.tar.gz" | sha256sum --check && \
|
|
mkdir pg_jsonschema-src && cd pg_jsonschema-src && tar xvzf ../pg_jsonschema.tar.gz --strip-components=1 -C . && \
|
|
sed -i 's/pgrx = "0.10.2"/pgrx = { version = "0.10.2", features = [ "unsafe-postgres" ] }/g' Cargo.toml && \
|
|
cargo pgrx install --release && \
|
|
echo "trusted = true" >> /usr/local/pgsql/share/extension/pg_jsonschema.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-graphql-pg-build"
|
|
# Compile "pg_graphql" extension
|
|
#
|
|
#########################################################################################
|
|
|
|
FROM rust-extensions-build AS pg-graphql-pg-build
|
|
ARG PG_VERSION
|
|
|
|
RUN wget https://github.com/supabase/pg_graphql/archive/refs/tags/v1.4.0.tar.gz -O pg_graphql.tar.gz && \
|
|
echo "bd8dc7230282b3efa9ae5baf053a54151ed0e66881c7c53750e2d0c765776edc pg_graphql.tar.gz" | sha256sum --check && \
|
|
mkdir pg_graphql-src && cd pg_graphql-src && tar xvzf ../pg_graphql.tar.gz --strip-components=1 -C . && \
|
|
sed -i 's/pgrx = "=0.10.2"/pgrx = { version = "0.10.2", features = [ "unsafe-postgres" ] }/g' Cargo.toml && \
|
|
cargo pgrx install --release && \
|
|
# it's needed to enable extension because it uses untrusted C language
|
|
sed -i 's/superuser = false/superuser = true/g' /usr/local/pgsql/share/extension/pg_graphql.control && \
|
|
echo "trusted = true" >> /usr/local/pgsql/share/extension/pg_graphql.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-tiktoken-build"
|
|
# Compile "pg_tiktoken" extension
|
|
#
|
|
#########################################################################################
|
|
|
|
FROM rust-extensions-build AS pg-tiktoken-pg-build
|
|
ARG PG_VERSION
|
|
|
|
# 26806147b17b60763039c6a6878884c41a262318 made on 26/09/2023
|
|
RUN wget https://github.com/kelvich/pg_tiktoken/archive/26806147b17b60763039c6a6878884c41a262318.tar.gz -O pg_tiktoken.tar.gz && \
|
|
echo "e64e55aaa38c259512d3e27c572da22c4637418cf124caba904cd50944e5004e pg_tiktoken.tar.gz" | sha256sum --check && \
|
|
mkdir pg_tiktoken-src && cd pg_tiktoken-src && tar xvzf ../pg_tiktoken.tar.gz --strip-components=1 -C . && \
|
|
cargo pgrx install --release && \
|
|
echo "trusted = true" >> /usr/local/pgsql/share/extension/pg_tiktoken.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg-pgx-ulid-build"
|
|
# Compile "pgx_ulid" extension
|
|
#
|
|
#########################################################################################
|
|
|
|
FROM rust-extensions-build AS pg-pgx-ulid-build
|
|
ARG PG_VERSION
|
|
|
|
RUN wget https://github.com/pksunkara/pgx_ulid/archive/refs/tags/v0.1.3.tar.gz -O pgx_ulid.tar.gz && \
|
|
echo "ee5db82945d2d9f2d15597a80cf32de9dca67b897f605beb830561705f12683c pgx_ulid.tar.gz" | sha256sum --check && \
|
|
mkdir pgx_ulid-src && cd pgx_ulid-src && tar xvzf ../pgx_ulid.tar.gz --strip-components=1 -C . && \
|
|
echo "******************* Apply a patch for Postgres 16 support; delete in the next release ******************" && \
|
|
wget https://github.com/pksunkara/pgx_ulid/commit/f84954cf63fc8c80d964ac970d9eceed3c791196.patch && \
|
|
patch -p1 < f84954cf63fc8c80d964ac970d9eceed3c791196.patch && \
|
|
echo "********************************************************************************************************" && \
|
|
sed -i 's/pgrx = "=0.10.2"/pgrx = { version = "=0.10.2", features = [ "unsafe-postgres" ] }/g' Cargo.toml && \
|
|
cargo pgrx install --release && \
|
|
echo "trusted = true" >> /usr/local/pgsql/share/extension/ulid.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "wal2json-build"
|
|
# Compile "wal2json" extension
|
|
#
|
|
#########################################################################################
|
|
|
|
FROM build-deps AS wal2json-pg-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN wget https://github.com/eulerto/wal2json/archive/refs/tags/wal2json_2_5.tar.gz && \
|
|
echo "b516653575541cf221b99cf3f8be9b6821f6dbcfc125675c85f35090f824f00e wal2json_2_5.tar.gz" | sha256sum --check && \
|
|
mkdir wal2json-src && cd wal2json-src && tar xvzf ../wal2json_2_5.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg_ivm"
|
|
# compile pg_ivm extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-ivm-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN wget https://github.com/sraoss/pg_ivm/archive/refs/tags/v1.7.tar.gz -O pg_ivm.tar.gz && \
|
|
echo "ebfde04f99203c7be4b0e873f91104090e2e83e5429c32ac242d00f334224d5e pg_ivm.tar.gz" | sha256sum --check && \
|
|
mkdir pg_ivm-src && cd pg_ivm-src && tar xvzf ../pg_ivm.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pg_ivm.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "pg_partman"
|
|
# compile pg_partman extension
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS pg-partman-build
|
|
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
|
|
ENV PATH "/usr/local/pgsql/bin/:$PATH"
|
|
RUN wget https://github.com/pgpartman/pg_partman/archive/refs/tags/v5.0.1.tar.gz -O pg_partman.tar.gz && \
|
|
echo "75b541733a9659a6c90dbd40fccb904a630a32880a6e3044d0c4c5f4c8a65525 pg_partman.tar.gz" | sha256sum --check && \
|
|
mkdir pg_partman-src && cd pg_partman-src && tar xvzf ../pg_partman.tar.gz --strip-components=1 -C . && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) install && \
|
|
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pg_partman.control
|
|
|
|
#########################################################################################
|
|
#
|
|
# Layer "neon-pg-ext-build"
|
|
# compile neon extensions
|
|
#
|
|
#########################################################################################
|
|
FROM build-deps AS neon-pg-ext-build
|
|
ARG PG_VERSION
|
|
|
|
# Public extensions
|
|
COPY --from=postgis-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=postgis-build /sfcgal/* /
|
|
COPY --from=plv8-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=h3-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=h3-pg-build /h3/usr /
|
|
COPY --from=unit-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=vector-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pgjwt-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-jsonschema-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-graphql-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-tiktoken-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=hypopg-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-hashids-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=rum-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pgtap-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=ip4r-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=prefix-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=hll-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=plpgsql-check-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=timescaledb-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-hint-plan-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=kq-imcx-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-cron-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-pgx-ulid-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=rdkit-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-uuidv7-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-roaringbitmap-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-semver-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-embedding-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=wal2json-pg-build /usr/local/pgsql /usr/local/pgsql
|
|
COPY --from=pg-anon-pg-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-ivm-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY --from=pg-partman-build /usr/local/pgsql/ /usr/local/pgsql/
|
|
COPY pgxn/ pgxn/
|
|
|
|
RUN make -j $(getconf _NPROCESSORS_ONLN) \
|
|
PG_CONFIG=/usr/local/pgsql/bin/pg_config \
|
|
-C pgxn/neon \
|
|
-s install && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) \
|
|
PG_CONFIG=/usr/local/pgsql/bin/pg_config \
|
|
-C pgxn/neon_utils \
|
|
-s install && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) \
|
|
PG_CONFIG=/usr/local/pgsql/bin/pg_config \
|
|
-C pgxn/neon_test_utils \
|
|
-s install && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) \
|
|
PG_CONFIG=/usr/local/pgsql/bin/pg_config \
|
|
-C pgxn/neon_rmgr \
|
|
-s install && \
|
|
case "${PG_VERSION}" in \
|
|
"v14" | "v15") \
|
|
;; \
|
|
"v16") \
|
|
echo "Skipping HNSW for PostgreSQL 16" && exit 0 \
|
|
;; \
|
|
*) \
|
|
echo "unexpected PostgreSQL version" && exit 1 \
|
|
;; \
|
|
esac && \
|
|
make -j $(getconf _NPROCESSORS_ONLN) \
|
|
PG_CONFIG=/usr/local/pgsql/bin/pg_config \
|
|
-C pgxn/hnsw \
|
|
-s install
|
|
|
|
#########################################################################################
|
|
#
|
|
# Compile and run the Neon-specific `compute_ctl` binary
|
|
#
|
|
#########################################################################################
|
|
FROM $REPOSITORY/$IMAGE:$TAG AS compute-tools
|
|
ARG BUILD_TAG
|
|
ENV BUILD_TAG=$BUILD_TAG
|
|
|
|
USER nonroot
|
|
# Copy entire project to get Cargo.* files with proper dependencies for the whole project
|
|
COPY --chown=nonroot . .
|
|
RUN cd compute_tools && mold -run cargo build --locked --profile release-line-debug-size-lto
|
|
|
|
#########################################################################################
|
|
#
|
|
# Final compute-tools image
|
|
#
|
|
#########################################################################################
|
|
|
|
FROM debian:bullseye-slim AS compute-tools-image
|
|
|
|
COPY --from=compute-tools /home/nonroot/target/release-line-debug-size-lto/compute_ctl /usr/local/bin/compute_ctl
|
|
|
|
#########################################################################################
|
|
#
|
|
# Clean up postgres folder before inclusion
|
|
#
|
|
#########################################################################################
|
|
FROM neon-pg-ext-build AS postgres-cleanup-layer
|
|
COPY --from=neon-pg-ext-build /usr/local/pgsql /usr/local/pgsql
|
|
|
|
# Remove binaries from /bin/ that we won't use (or would manually copy & install otherwise)
|
|
RUN cd /usr/local/pgsql/bin && rm ecpg raster2pgsql shp2pgsql pgtopo_export pgtopo_import pgsql2shp
|
|
|
|
# Remove headers that we won't need anymore - we've completed installation of all extensions
|
|
RUN rm -r /usr/local/pgsql/include
|
|
|
|
# Remove static postgresql libraries - all compilation is finished, so we
|
|
# can now remove these files - they must be included in other binaries by now
|
|
# if they were to be used by other libraries.
|
|
RUN rm /usr/local/pgsql/lib/lib*.a
|
|
|
|
#########################################################################################
|
|
#
|
|
# Final layer
|
|
# Put it all together into the final image
|
|
#
|
|
#########################################################################################
|
|
FROM debian:bullseye-slim
|
|
# Add user postgres
|
|
RUN mkdir /var/db && useradd -m -d /var/db/postgres postgres && \
|
|
echo "postgres:test_console_pass" | chpasswd && \
|
|
mkdir /var/db/postgres/compute && mkdir /var/db/postgres/specs && \
|
|
mkdir /var/db/postgres/pgbouncer && \
|
|
chown -R postgres:postgres /var/db/postgres && \
|
|
chmod 0750 /var/db/postgres/compute && \
|
|
chmod 0750 /var/db/postgres/pgbouncer && \
|
|
echo '/usr/local/lib' >> /etc/ld.so.conf && /sbin/ldconfig && \
|
|
# create folder for file cache
|
|
mkdir -p -m 777 /neon/cache
|
|
|
|
COPY --from=postgres-cleanup-layer --chown=postgres /usr/local/pgsql /usr/local
|
|
COPY --from=compute-tools --chown=postgres /home/nonroot/target/release-line-debug-size-lto/compute_ctl /usr/local/bin/compute_ctl
|
|
|
|
# Create remote extension download directory
|
|
RUN mkdir /usr/local/download_extensions && chown -R postgres:postgres /usr/local/download_extensions
|
|
|
|
# Install:
|
|
# libreadline8 for psql
|
|
# libicu67, locales for collations (including ICU and plpgsql_check)
|
|
# liblz4-1 for lz4
|
|
# libossp-uuid16 for extension ossp-uuid
|
|
# libgeos, libgdal, libsfcgal1, libproj and libprotobuf-c1 for PostGIS
|
|
# libxml2, libxslt1.1 for xml2
|
|
# libzstd1 for zstd
|
|
# libboost* for rdkit
|
|
# ca-certificates for communicating with s3 by compute_ctl
|
|
RUN apt update && \
|
|
apt install --no-install-recommends -y \
|
|
gdb \
|
|
libicu67 \
|
|
liblz4-1 \
|
|
libreadline8 \
|
|
libboost-iostreams1.74.0 \
|
|
libboost-regex1.74.0 \
|
|
libboost-serialization1.74.0 \
|
|
libboost-system1.74.0 \
|
|
libossp-uuid16 \
|
|
libgeos-c1v5 \
|
|
libgdal28 \
|
|
libproj19 \
|
|
libprotobuf-c1 \
|
|
libsfcgal1 \
|
|
libxml2 \
|
|
libxslt1.1 \
|
|
libzstd1 \
|
|
libcurl4-openssl-dev \
|
|
locales \
|
|
procps \
|
|
ca-certificates && \
|
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
|
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
|
|
|
|
ENV LANG en_US.utf8
|
|
USER postgres
|
|
ENTRYPOINT ["/usr/local/bin/compute_ctl"]
|