diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4d68714..8587b40 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,8 @@
stages:
- build-image
+ - test-image
include:
- local: '/extended-postgres/build-images-ci.yml'
+ - local: '/extended-postgres/test-images-ci.yml'
- local: '/migration-tools/build-images-migration-tools.yml'
diff --git a/README.md b/README.md
index a90f85a..d850d54 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ Storage-optimized: the size of each image is ~300-500 MiB.
Use these images with Database Lab, when you need HypoPG or anything else.
### What's inside
-Available PostgreSQL versions: 9.6, 10, 11, 12, 13, 14. Extensions:
+Available PostgreSQL versions: 9.6 (EOL), 10 (EOL), 11 (EOL), 12(EOL), 13, 14, 15, 16, 17. Extensions:
- all official ["core" contrib modules](https://www.postgresql.org/docs/current/contrib.html)
- [bg_mon](https://github.com/CyberDem0n/bg_mon)
- [Citus](https://github.com/citusdata/citus)
@@ -23,6 +23,7 @@ Available PostgreSQL versions: 9.6, 10, 11, 12, 13, 14. Extensions:
- [pg_repack](https://github.com/reorg/pg_repack)
- [pg_show_plans](https://github.com/cybertec-postgresql/pg_show_plans)
- [pg_stat_kcache](https://github.com/powa-team/pg_stat_kcache)
+- [pg_wait_sampling](https://github.com/postgrespro/pg_wait_sampling)
- [pg_timetable](https://github.com/cybertec-postgresql/pg_timetable)
- [pgaudit](https://github.com/pgaudit/pgaudit)
- [pgextwlist](https://github.com/dimitri/pgextwlist)
@@ -31,91 +32,13 @@ Available PostgreSQL versions: 9.6, 10, 11, 12, 13, 14. Extensions:
- [postgresql_anonymizer](https://github.com/webysther/postgresql_anonymizer)
- [PoWA](https://github.com/powa-team/powa)
- [set_user](https://github.com/pgaudit/set_user)
-- [Timescale](https://github.com/timescale/timescaledb)
-
-#### Not included in the PostgreSQL 14 image (yet)
-The PostgreSQL 14 image is now missing the following extensions (they will be added in the future):
-- pg_auth_mon
+- [timescaledb](https://github.com/timescale/timescaledb)
+- [pgvector](https://github.com/pgvector/pgvector)
### How to extend
- You can fork this repository and extend `Dockerfile`, then build your own images
- Proposals to add more extensions to this repository are welcome https://gitlab.com/postgres-ai/custom-images/-/issues
-### The complete list of available extensions
-| name | version
(9.6) | version
(10) | version
(11) | version
(12) | version
(13) | version
(14) | comment |
-| --- | --- | --- | --- | --- | --- | --- | --- |
-| adminpack | 1.1 | 1.1 | 2.0 | 2.0 | 2.1 | 2.1 | administrative functions for PostgreSQL |
-| amcheck | 2 | 1.0 | 1.1 | 1.2 | 1.2 | 1.3 | functions for verifying relation integrity. ("amcheck_next" for Postgres 9.6) |
-| anon | 1.0.0 | 1.0.0 | 1.0.0 | 1.0.0 | 1.0.0 | 1.0.0 | Data anonymization tools |
-| autoinc | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | functions for autoincrementing fields |
-| bloom | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | bloom access method - signature file based index |
-| btree_gin | 1.0 | 1.2 | 1.3 | 1.3 | 1.3 | 1.3 | support for indexing common datatypes in GIN |
-| btree_gist | 1.2 | 1.5 | 1.5 | 1.5 | 1.5 | 1.6 | support for indexing common datatypes in GiST |
-| citext | 1.3 | 1.4 | 1.5 | 1.6 | 1.6 | 1.6 | data type for case-insensitive character strings |
-| citus | 8.0 | 8.3 | 10.0 | 10.2 | 11.0 | 11.0 | Citus distributed database |
-| cube | 1.2 | 1.2 | 1.4 | 1.4 | 1.4 | 1.5 | data type for multidimensional cubes |
-| dblink | 1.2 | 1.2 | 1.2 | 1.2 | 1.2 | 1.2 | connect to other PostgreSQL databases from within a database |
-| ddlx | 0.22 | 0.22 | 0.22 | 0.22 | 0.22 | 0.22 | DDL eXtractor functions |
-| dict_int | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | text search dictionary template for integers |
-| dict_xsyn | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | text search dictionary template for extended synonym processing |
-| earthdistance | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | calculate great-circle distances on the surface of the Earth |
-| file_fdw | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | foreign-data wrapper for flat file access |
-| fuzzystrmatch | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | determine similarities and distance between strings |
-| hll | 2.16 | 2.1 | 2.16 | 2.16 | 2.16 | 2.16 | type for storing hyperloglog data |
-| hstore | 1.4 | 1.4 | 1.5 | 1.6 | 1.7 | 1.8 | data type for storing sets of (key, value) pairs |
-| hstore_plpython3u | 1.0 | 1.0 | 1.0 | 1 .0 | 1.0 | 1.0 | transform between hstore and plpython3u |
-| hypopg | 1.3.1 | 1.3.1 | 1.3.1 | 1.3.1 | 1.3.1 | 1.3.1 | Hypothetical indexes for PostgreSQL |
-| insert_username | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | functions for tracking who changed a table |
-| intagg | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | integer aggregator and enumerator (obsolete) |
-| intarray | 1.2 | 1.2 | 1.2 | 1.2 | 1.3 | 1.5 | functions, operators, and index support for 1-D arrays of integers |
-| isn | 1.1 | 1.1 | 1.2 | 1.2 | 1.2 | 1.2 | data types for international product numbering standards |
-| jsonb_plpython3u | | | 1.0 | 1.0 | 1.0 | 1.0 | transform between jsonb and plpython3u |
-| lo | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | Large Object maintenance |
-| logerrors | | 2.0 | 2.0 | 2.0 | 2.0 | 2.0 | Function for collecting statistics about messages in logfile
-| ltree | 1.1 | 1.1 | 1.1 | 1.1 | 1.2 | 1.2 | data type for hierarchical tree-like structures |
-| ltree_plpython3u | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | transform between ltree and plpython3u |
-| moddatetime | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | functions for tracking last modification time |
-| moddatetime | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | functions for tracking last modification time |
-| old_snapshot | | | | | | 1.0 | iutilities in support of old_snapshot_threshold |
-| pg_auth_mon | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | | monitor connection attempts per user |
-| pg_buffercache | 1.2 | 1.3 | 1.3 | 1.3 | 1.3 | 1.3 | examine the shared buffer cache |
-| pg_cron | 1.4 | 1.4 | 1.4 | 1.4 | 1.4 | 1.4 | Job scheduler for PostgreSQL |
-| pg_freespacemap | 1.1 | 1.2 | 1.2 | 1.2 | 1.2 | 1.2 | examine the free space map (FSM) |
-| pg_hint_plan | 1.2.7 | 1.3.6 | 1.3.7 | 1.3.7 | 1.3.7 | 1.4 | makes it possible to tweak PostgreSQL execution plans using so-called "hints" in SQL comments |
-| pg_prewarm | 1.1 | 1.1 | 1.2 | 1.2 | 1.2 | 1.2 | prewarm relation data |
-| pg_qualstats | 2.0.3 | 2.0.4 | 2.0.4 | 2.0.4 | 2.0.4 | 2.0.4 | An extension collecting statistics about quals |
-| pg_repack | 1.4.7 | 1.4.7 | 1.4.7 | 1.4.7 | 1.4.7 | 1.4.7 | Reorganize tables in PostgreSQL databases with minimal locks |
-| pg_show_plans | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | show query plans of all currently running SQL statements |
-| pg_stat_kcache | 2.2.0 | 2.2.1 | 2.2.1 | 2.2.1 | 2.2.1 | 2.2.1 | Kernel statistics gathering |
-| pg_wait_sampling | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | sampling based statistics of wait events |
-| pg_stat_statements | 1.4 | 1.6 | 1.6 | 1.7 | 1.8 | 1.9 | track execution statistics of all SQL statements executed |
-| pg_surgery | | | | | | 1.0 | extension to perform surgery on a damaged relation |
-| pg_trgm | 1.3 | 1.3 | 1.4 | 1.4 | 1.5 | 1.6 | text similarity measurement and index searching based on trigrams |
-| pg_visibility | 1.1 | 1.2 | 1.2 | 1.2 | 1.2 | 1.2 | examine the visibility map (VM) and page-level visibility info |
-| pgaudit | 1.1.4 | 1.2.4 | 1.3.4 | 1.4.3 | 1.5.2 | 1.6.2 | provides auditing functionality |
-| pgcrypto | 1.3 | 1.3 | 1.3 | 1.3 | 1.3 | 1.3 | cryptographic functions |
-| pgrowlocks | 1.2 | 1.2 | 1.2 | 1.2 | 1.2 | 1.2 | show row-level locking information |
-| pgstattuple | 1.4 | 1.5 | 1.5 | 1.5 | 1.5 | 1.5 | show tuple-level statistics |
-| plpgsql | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | PL/pgSQL procedural language |
-| plpython3u | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | PL/Python3U untrusted procedural language |
-| postgres_fdw | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.1 | foreign-data wrapper for remote PostgreSQL servers |
-| powa | 4.1.2 | 4.1.4 | 4.1.4 | 4.1.4 | 4.1.4 | 4.1.4 | PostgreSQL Workload Analyser-core |
-| refint | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | functions for implementing referential integrity (obsolete) |
-| seg | 1.1 | 1.1 | 1.3 | 1.3 | 1.3 | 1.4 | data type for representing line segments or floating-point intervals |
-| set_user | 3.0 | 3.0 | 3.0 | 3.0 | 3.0 | 3.0 | similar to SET ROLE but with added logging |
-| sslinfo | 1.2 | 1.2 | 1.2 | 1.2 | 1.2 | 1.2 | information about SSL certificates |
-| tablefunc | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | functions that manipulate whole tables, including crosstab |
-| tcn | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | Triggered change notifications |
-| timescaledb | 1.7.5 | 1.7.5 | 2.3.1 | 2.7.1 | 2.7.1 | 2.7.1 | Enables scalable inserts and complex queries for time-series data |
-| timetravel | 1.0 | 1.0 | 1.0 | | | | functions for implementing time travel |
-| topn | 2.3.0 | 2.3.0 | 2.4.0 | 2.4.0 | 2.4.0 | 2.4.0 | type for top-n JSONB |
-| tsm_system_rows | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | 1.0 | TABLESAMPLE method which accepts number of rows as a limit |
-| tsm_system_time | 1.0 | 1.0 | 1.0 | 1.0 | 11.0 | 1.0 | TABLESAMPLE method which accepts time in milliseconds as a limit |
-| unaccent | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | text search dictionary that removes accents |
-| uuid-ossp | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | 1.1 | generate universally unique identifiers (UUIDs) |
-| xml2 | 1.1 |1.1 | 1.1 | 1.1 | 1.1 | 1.1 | XPath querying and XSLT |
-
### PostgreSQL Tools:
- [WAL-G](https://github.com/wal-g/wal-g)
- [pgBackRest](https://github.com/pgbackrest/pgbackrest)
-
diff --git a/extended-postgres/Dockerfile b/extended-postgres/Dockerfile
index 9d33637..e36ce8e 100644
--- a/extended-postgres/Dockerfile
+++ b/extended-postgres/Dockerfile
@@ -1,194 +1,202 @@
-ARG PG_SERVER_VERSION=14
+# Debian 11 (bullseye) has glibc 2.31.
+# If you are using "physical" mode, please check the glibc version in your production database system to avoid potential index corruption.
+# You should have the same version of glibc as in your Docker image.
-# build-env
-FROM postgres:${PG_SERVER_VERSION} as build-env
-
-ARG WALG_VERSION
-ENV WALG_VERSION=${WALG_VERSION:-2.0.0}
-
-ARG GO_VERSION
-ENV GO_VERSION=${GO_VERSION:-1.18.4}
-
-RUN apt-get clean && rm -rf /var/lib/apt/lists/partial \
- # add the backports repository for Debian 9 Stretch. Required to install the package "libbrotli-dev"
- && if [ $(sed 's/\..*//' /etc/debian_version) = "9" ]; then \
- echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list; \
- fi \
- # install dependencies
- && apt-get update -o Acquire::CompressionTypes::Order::=gz \
- && apt-get install --no-install-recommends -y apt-transport-https ca-certificates \
- wget curl sudo git make cmake gcc build-essential \
- libbrotli-dev liblzo2-dev libsodium-dev \
- # install Go
- && cd /tmp && wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz \
- && rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz \
- && export PATH=$PATH:/usr/local/go/bin \
- # build WAL-G
- && git clone --branch v${WALG_VERSION} --single-branch https://github.com/wal-g/wal-g.git \
- && cd wal-g && export USE_LIBSODIUM=1 && export USE_LZO=1 \
- && make deps && GOBIN=/usr/local/bin make pg_install
+ARG PG_SERVER_VERSION=16
# Build the extended image
-FROM postgres:${PG_SERVER_VERSION}
+FROM postgres:${PG_SERVER_VERSION}-bullseye
LABEL maintainer="postgres.ai"
-COPY --from=build-env /usr/local/bin/wal-g /usr/local/bin/wal-g
-
ARG PG_SERVER_VERSION
-ENV PG_SERVER_VERSION=${PG_SERVER_VERSION:-14}
+ENV PG_SERVER_VERSION=${PG_SERVER_VERSION:-16}
+
+ARG PG_UNIX_SOCKET_DIR
+ENV PG_UNIX_SOCKET_DIR=${PG_UNIX_SOCKET_DIR:-"/var/run/postgresql"}
-ARG PGBR_VERSION
-ENV PGBR_VERSION=${PGBR_VERSION:-2.39}
+ARG PG_SERVER_PORT
+ENV PG_SERVER_PORT=${PG_SERVER_PORT:-5432}
+
+ARG WALG_VERSION
+ENV WALG_VERSION=${WALG_VERSION:-3.0.5}
ARG PG_TIMETABLE_VERSION
-ENV PG_TIMETABLE_VERSION=${PG_TIMETABLE_VERSION:-4.8.0}
+ENV PG_TIMETABLE_VERSION=${PG_TIMETABLE_VERSION:-5.11.0}
+
+ARG LOGERRORS_VERSION
+ENV LOGERRORS_VERSION=${LOGERRORS_VERSION:-2.1.3}
+
+ARG PGVECTOR_VERSION
+ENV PGVECTOR_VERSION=${PGVECTOR_VERSION:-0.8.0}
+
+# https://gitlab.com/postgres-ai/custom-images/-/merge_requests/56
+ARG PG_CRON_VERSION
+ENV PG_CRON_VERSION=${PG_CRON_VERSION:-1.4.2}
+
RUN apt-get clean && rm -rf /var/lib/apt/lists/partial \
- # add the backports repository for Debian 9 Stretch. Required to install the package "libbrotli-dev"
- && if [ $(sed 's/\..*//' /etc/debian_version) = "9" ]; then \
- echo "deb http://deb.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/backports.list; \
- fi \
+ # remove the "beta" and "rc" suffix in the PG_SERVER_VERSION variable (if exists)
+ && PG_SERVER_VERSION="$( echo ${PG_SERVER_VERSION} | sed 's/beta.*//' | sed 's/rc.*//' )" \
&& apt-get update -o Acquire::CompressionTypes::Order::=gz \
&& apt-get install --no-install-recommends -y wget make gcc unzip sudo git \
curl libc6-dev apt-transport-https ca-certificates pgxnclient bc \
- build-essential libssl-dev krb5-multidev libkrb5-dev lsb-release apt-utils \
- && apt-get install --no-install-recommends -y \
- postgresql-server-dev-${PG_SERVER_VERSION} \
+ build-essential libssl-dev krb5-multidev libkrb5-dev lsb-release apt-utils flex \
+ && apt-get install --no-install-recommends -y postgresql-server-dev-${PG_SERVER_VERSION} \
# plpython3 (procedural language implementation for Python 3.x)
- && apt-get install --no-install-recommends -y \
- postgresql-plpython3-${PG_SERVER_VERSION} \
+ && apt-get install --no-install-recommends -y postgresql-plpython3-${PG_SERVER_VERSION} \
# amcheck extension; not included in contrib for Postgres 9.6
&& if [ "${PG_SERVER_VERSION}" = "9.6" ]; then \
- apt-get install --no-install-recommends -y \
- postgresql-9.6-amcheck; \
+ apt-get install --no-install-recommends -y postgresql-9.6-amcheck; \
fi \
# pg_repack extension
- && apt-get install --no-install-recommends -y \
- postgresql-${PG_SERVER_VERSION}-repack \
+ && apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-repack \
# hypopg extension
&& apt-get install --no-install-recommends -y \
- postgresql-${PG_SERVER_VERSION}-hypopg \
- postgresql-${PG_SERVER_VERSION}-hypopg-dbgsym \
+ postgresql-${PG_SERVER_VERSION}-hypopg \
+ postgresql-${PG_SERVER_VERSION}-hypopg-dbgsym \
# pgaudit extension
- && apt-get install --no-install-recommends -y \
- postgresql-${PG_SERVER_VERSION}-pgaudit \
+ && apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-pgaudit \
# pg_hint_plan extension
- && if [ $(echo "$PG_SERVER_VERSION < 14" | /usr/bin/bc) = "1" ]; then \
+ && if [ $(echo "$PG_SERVER_VERSION > 11" | /usr/bin/bc) = "1" ] && [ $(echo "$PG_SERVER_VERSION < 17" | /usr/bin/bc) = "1" ]; then \
+ apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-pg-hint-plan; \
+ else \
export PG_PLAN_HINT_VERSION=$(echo $PG_SERVER_VERSION | sed 's/\.//') \
- && wget --quiet -O /tmp/pg_hint_plan.zip \
- https://github.com/ossc-db/pg_hint_plan/archive/PG${PG_PLAN_HINT_VERSION}.zip \
- && unzip /tmp/pg_hint_plan.zip -d /tmp \
- && cd /tmp/pg_hint_plan-PG${PG_PLAN_HINT_VERSION} \
- && make && make install; \
- # there is no branch "PG14", use the tag "REL14_1_4_0"
- elif [ "${PG_SERVER_VERSION}" = "14" ]; then \
- wget --quiet -O /tmp/pg_hint_plan.zip \
- https://github.com/ossc-db/pg_hint_plan/archive/REL14_1_4_0.zip \
+ && wget --quiet -O /tmp/pg_hint_plan.zip https://github.com/ossc-db/pg_hint_plan/archive/PG${PG_PLAN_HINT_VERSION}.zip \
&& unzip /tmp/pg_hint_plan.zip -d /tmp \
- && cd /tmp/pg_hint_plan-REL14_1_4_0 \
- && make && make install; \
- fi \
+ && cd /tmp/pg_hint_plan-PG${PG_PLAN_HINT_VERSION} \
+ && make && make install; \
+ fi \
# powa extension
- && apt-get install --no-install-recommends -y \
- postgresql-${PG_SERVER_VERSION}-powa \
+ && apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-powa \
# pg_auth_mon extension
- && if [ $(echo "$PG_SERVER_VERSION < 14" | /usr/bin/bc) = "1" ]; then \
- git clone https://github.com/RafiaSabih/pg_auth_mon.git \
+ && if [ "${PG_SERVER_VERSION}" = "9.6" ]; then \
+ cd /tmp && git clone --branch v1.0 --single-branch https://github.com/RafiaSabih/pg_auth_mon.git \
+ && cd pg_auth_mon && USE_PGXS=1 make && USE_PGXS=1 make install; \
+ elif [ $(echo "$PG_SERVER_VERSION > 10" | /usr/bin/bc) = "1" ]; then \
+ cd /tmp && git clone --branch v3.0 --single-branch https://github.com/RafiaSabih/pg_auth_mon.git \
&& cd pg_auth_mon && USE_PGXS=1 make && USE_PGXS=1 make install; \
fi \
# timescaledb extension
- && if [ $(echo "$PG_SERVER_VERSION < 11" | /usr/bin/bc) = "1" ]; then \
- echo 'deb https://packagecloud.io/timescale/timescaledb/debian/' \
- $(env -i bash -c '. /etc/os-release; echo ${VERSION_CODENAME}') \
- 'main' > /etc/apt/sources.list.d/timescaledb.list \
- && wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo apt-key add - \
- && apt-get update \
- && apt-get install --no-install-recommends -y \
- timescaledb-postgresql-${PG_SERVER_VERSION}; \
- elif [ $(echo "$PG_SERVER_VERSION < 15" | /usr/bin/bc) = "1" ]; then \
+ && if [ $(echo "$PG_SERVER_VERSION > 11" | /usr/bin/bc) = "1" ]; then \
echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/timescaledb.list \
&& wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo apt-key add - \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
timescaledb-2-postgresql-${PG_SERVER_VERSION}; \
fi \
- # citus extension; the latest versions only support Postgres 13+
- && if [ "${PG_SERVER_VERSION}" = "9.6" ]; then CITUS_VERSION="8.0"; \
- elif [ "${PG_SERVER_VERSION}" = "10" ]; then CITUS_VERSION="8.3"; \
- elif [ "${PG_SERVER_VERSION}" = "11" ]; then CITUS_VERSION="10.0"; \
- elif [ "${PG_SERVER_VERSION}" = "12" ]; then CITUS_VERSION="10.2"; \
- elif [ $(echo "$PG_SERVER_VERSION > 12" | /usr/bin/bc) = "1" ]; then CITUS_VERSION="11.0"; \
+ # citus extension
+ && if [ $(echo "$PG_SERVER_VERSION > 10" | /usr/bin/bc) = "1" ]; then \
+ if [ "${PG_SERVER_VERSION}" = "11" ]; then CITUS_VERSION="10.0"; \
+ elif [ "${PG_SERVER_VERSION}" = "12" ]; then CITUS_VERSION="10.2"; \
+ elif [ "${PG_SERVER_VERSION}" = "13" ]; then CITUS_VERSION="11.3"; \
+ elif [ "${PG_SERVER_VERSION}" = "14" ]; then CITUS_VERSION="12.1"; \
+ elif [ "${PG_SERVER_VERSION}" = "15" ]; then CITUS_VERSION="13.0"; \
+ elif [ "${PG_SERVER_VERSION}" = "16" ]; then CITUS_VERSION="13.0"; \
+ elif [ "${PG_SERVER_VERSION}" = "17" ]; then CITUS_VERSION="13.0"; \
+ fi \
+ && curl -s https://install.citusdata.com/community/deb.sh | bash \
+ && apt-get install --no-install-recommends -y postgresql-"${PG_SERVER_VERSION}"-citus-"${CITUS_VERSION}"; \
fi \
- && curl -s https://install.citusdata.com/community/deb.sh | bash \
- && apt-get install --no-install-recommends -y \
- postgresql-"${PG_SERVER_VERSION}"-citus-"${CITUS_VERSION}" \
# hll extension
- && apt-get install --no-install-recommends -y \
- postgresql-"${PG_SERVER_VERSION}"-hll \
+ && apt-get install --no-install-recommends -y postgresql-"${PG_SERVER_VERSION}"-hll \
# topn extension
- && apt-get install --no-install-recommends -y \
- postgresql-"${PG_SERVER_VERSION}"-topn \
+ && if [ $(echo "$PG_SERVER_VERSION > 9.6" | /usr/bin/bc) = "1" ]; then \
+ curl -s https://install.citusdata.com/community/deb.sh | bash \
+ && apt-get install --no-install-recommends -y postgresql-"${PG_SERVER_VERSION}"-topn; \
+ fi \
# pg_timetable extension
- && wget https://github.com/cybertec-postgresql/pg_timetable/releases/download/v${PG_TIMETABLE_VERSION}/pg_timetable_${PG_TIMETABLE_VERSION}_Linux_x86_64.deb \
- && dpkg -i pg_timetable_${PG_TIMETABLE_VERSION}_Linux_x86_64.deb \
- && rm -rf pg_timetable_${PG_TIMETABLE_VERSION}_Linux_x86_64.deb \
+ && wget https://github.com/cybertec-postgresql/pg_timetable/releases/download/v"${PG_TIMETABLE_VERSION}"/pg_timetable_Linux_x86_64.deb \
+ && dpkg -i pg_timetable_Linux_x86_64.deb \
+ && rm -rf pg_timetable_Linux_x86_64.deb \
# pg_show_plans extension
- && git clone https://github.com/cybertec-postgresql/pg_show_plans.git \
- && cd pg_show_plans \
- && export USE_PGXS=1 && make && make install && cd .. && rm -rf pg_show_plans \
+ && if [ $(echo "$PG_SERVER_VERSION > 11" | /usr/bin/bc) = "1" ]; then \
+ apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-show-plans; \
+ fi \
# pg_cron extension
- && apt-get install --no-install-recommends -y \
- postgresql-${PG_SERVER_VERSION}-cron \
+ # for PostgreSQL 10-15, install from source (https://gitlab.com/postgres-ai/custom-images/-/merge_requests/56)
+ && if [ $(echo "$PG_SERVER_VERSION >= 10" | /usr/bin/bc) = "1" ] && [ $(echo "$PG_SERVER_VERSION < 16" | /usr/bin/bc) = "1" ]; then \
+ cd /tmp && git clone --branch v${PG_CRON_VERSION} --single-branch https://github.com/citusdata/pg_cron.git \
+ && cd pg_cron \
+ && make && make install; \
+ elif [ $(echo "$PG_SERVER_VERSION == 9.6" | /usr/bin/bc) = "1" ]; then \
+ cd /tmp && git clone --branch v1.3.1 --single-branch https://github.com/citusdata/pg_cron.git \
+ && cd pg_cron \
+ && make && make install; \
+ elif [ $(echo "$PG_SERVER_VERSION >= 16" | /usr/bin/bc) = "1" ]; then \
+ apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-cron; \
+ fi \
# postgresql_anonymizer extension
- && pgxn install ddlx && pgxn install postgresql_anonymizer \
+ && if [ $(echo "$PG_SERVER_VERSION > 9.6" | /usr/bin/bc) = "1" ]; then \
+ pgxn install ddlx && pgxn install postgresql_anonymizer; \
+ fi \
# pg_stat_kcache extension
- && apt-get install --no-install-recommends -y \
- postgresql-${PG_SERVER_VERSION}-pg-stat-kcache \
+ && apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-pg-stat-kcache \
# pg_wait_sampling extension
- && apt-get install --no-install-recommends -y \
- postgresql-${PG_SERVER_VERSION}-pg-wait-sampling \
+ && apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-pg-wait-sampling \
# pg_qualstats extension
- && apt-get install --no-install-recommends -y \
- postgresql-${PG_SERVER_VERSION}-pg-qualstats \
+ && apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-pg-qualstats \
# bg_mon extension
&& apt-get install -y libevent-dev libbrotli-dev \
- && git clone https://github.com/CyberDem0n/bg_mon.git && cd bg_mon \
+ && cd /tmp && git clone https://github.com/CyberDem0n/bg_mon.git && cd bg_mon \
&& USE_PGXS=1 make && USE_PGXS=1 make install && cd .. \
# pgextwlist extension
- && apt-get install --no-install-recommends -y \
- postgresql-${PG_SERVER_VERSION}-pgextwlist \
+ && apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-pgextwlist \
# set_user extension
- && git clone https://github.com/pgaudit/set_user.git \
- && cd set_user && git checkout REL3_0_0 && make USE_PGXS=1 && make USE_PGXS=1 install \
+ && if [ $(echo "$PG_SERVER_VERSION > 9.6" | /usr/bin/bc) = "1" ] && [ $(echo "$PG_SERVER_VERSION < 17" | /usr/bin/bc) = "1" ]; then \
+ apt-get install --no-install-recommends -y postgresql-${PG_SERVER_VERSION}-set-user; \
+ elif [ $(echo "$PG_SERVER_VERSION == 17" | /usr/bin/bc) = "1" ]; then \
+ cd /tmp && git clone --branch REL4_1_0 https://github.com/pgaudit/set_user.git \
+ && cd set_user && make USE_PGXS=1 && make USE_PGXS=1 install; \
+ elif [ $(echo "$PG_SERVER_VERSION == 9.6" | /usr/bin/bc) = "1" ]; then \
+ cd /tmp && git clone --branch REL4_0_1 https://github.com/pgaudit/set_user.git \
+ && cd set_user && make USE_PGXS=1 && make USE_PGXS=1 install; \
+ fi \
# logerrors extension
&& if [ $(echo "$PG_SERVER_VERSION > 9.6" | /usr/bin/bc) = "1" ]; then \
- cd /tmp && wget https://github.com/munakoiso/logerrors/archive/v2.0.tar.gz \
- && tar -xf v2.0.tar.gz && rm v2.0.tar.gz && cd logerrors-2.0 \
- && USE_PGXS=1 make && USE_PGXS=1 make install; \
+ cd /tmp && wget -O logerrors.tar.gz https://github.com/munakoiso/logerrors/archive/v${LOGERRORS_VERSION}.tar.gz \
+ && tar -xf logerrors.tar.gz && rm logerrors.tar.gz && cd logerrors-${LOGERRORS_VERSION} \
+ && USE_PGXS=1 make && USE_PGXS=1 make install; \
+ fi \
+ # pgvector extension
+ && if [ $(echo "$PG_SERVER_VERSION >= 11" | /usr/bin/bc) = "1" ]; then \
+ if [ "${PG_SERVER_VERSION}" = "11" ]; then PGVECTOR_VERSION="0.5.1"; \
+ elif [ "${PG_SERVER_VERSION}" = "12" ]; then PGVECTOR_VERSION="0.7.4"; \
+ else PGVECTOR_VERSION="${PGVECTOR_VERSION}"; \
+ fi \
+ && cd /tmp && git clone --branch v${PGVECTOR_VERSION} https://github.com/pgvector/pgvector.git \
+ && cd pgvector && make OPTFLAGS="" install \
+ && mkdir /usr/share/doc/pgvector \
+ && cp LICENSE README.md /usr/share/doc/pgvector \
+ && cp sql/vector.sql /usr/share/postgresql/${PG_SERVER_VERSION}/extension/vector--${PGVECTOR_VERSION}.sql; \
fi \
# pgBackRest
&& apt-get install --no-install-recommends -y \
- pgbackrest=${PGBR_VERSION}* zstd openssh-client \
+ pgbackrest zstd openssh-client \
&& mkdir -p -m 700 /var/lib/postgresql/.ssh \
&& chown postgres:postgres /var/lib/postgresql/.ssh \
+ # WAL-G
+ && wget https://github.com/wal-g/wal-g/releases/download/v"${WALG_VERSION}"/wal-g-pg-ubuntu-20.04-amd64.tar.gz \
+ && tar -zxvf wal-g-pg-ubuntu-20.04-amd64.tar.gz \
+ && mv wal-g-pg-ubuntu-20.04-amd64 /usr/local/bin/wal-g \
+ && wal-g --version \
# remove all auxilary packages to reduce final image size
&& cd / && rm -rf /tmp/* && apt-get purge -y --auto-remove \
gcc make wget unzip curl libc6-dev apt-transport-https git \
postgresql-server-dev-${PG_SERVER_VERSION} pgxnclient build-essential \
libssl-dev krb5-multidev comerr-dev krb5-multidev libkrb5-dev apt-utils lsb-release \
- libgssrpc4 libevent-dev libbrotli-dev \
+ libgssrpc4 \
&& apt-get clean -y autoclean \
&& rm -rf /var/lib/apt/lists/* \
# remove standard pgdata
&& rm -rf /var/lib/postgresql/${PG_SERVER_VERSION}/
-EXPOSE 5432
+EXPOSE ${PG_SERVER_PORT}
# Prepare Postgres start script
RUN echo "#!/bin/bash" > /pg_start.sh && chmod a+x /pg_start.sh \
- && echo "chown -R postgres:postgres \${PGDATA} /var/run/postgresql" \
+ && echo "chown -R postgres:postgres \${PGDATA} \${PG_UNIX_SOCKET_DIR}" \
>> /pg_start.sh \
- && printf "sudo -Eu postgres /usr/lib/postgresql/${PG_SERVER_VERSION}/bin/postgres -D \${PGDATA} >& /proc/1/fd/1 \n" \
+ && printf "sudo -Eu postgres /usr/lib/postgresql/$(echo ${PG_SERVER_VERSION} | sed 's/beta.*//' | sed 's/rc.*//')/bin/postgres -D \${PGDATA} -k \${PG_UNIX_SOCKET_DIR} -p \${PG_SERVER_PORT} >& /proc/1/fd/1 \n" \
>> /pg_start.sh \
# Infinite sleep to allow restarting Postgres
&& echo "/bin/bash -c \"trap : TERM INT; sleep infinity & wait\"" \
diff --git a/extended-postgres/build-images-ci.yml b/extended-postgres/build-images-ci.yml
index aea9dd5..9807e04 100644
--- a/extended-postgres/build-images-ci.yml
+++ b/extended-postgres/build-images-ci.yml
@@ -2,11 +2,11 @@ stages:
- build-image
.job_template: &build_image_definition_dh
- image: docker:19
+ image: docker:24.0.6
stage: build-image
services:
- alias: docker
- name: docker:19.03.5-dind
+ name: docker:24.0.6-dind
script:
- apk add --no-cache bash
- bash ./ci_docker_build_push.sh
@@ -18,11 +18,11 @@ stages:
DOCKER_NAME: "postgresai/extended-postgres"
.job_template: &build_image_definition_gl
- image: docker:19
+ image: docker:24.0.6
stage: build-image
services:
- alias: docker
- name: docker:19.03.5-dind
+ name: docker:24.0.6-dind
script:
- apk add --no-cache bash
- bash ./ci_docker_build_push.sh
@@ -94,6 +94,30 @@ build-extended-postgres-14-image-latest:
PG_SERVER_VERSION: "14"
TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_TAG}"
+build-extended-postgres-15-image-latest:
+ <<: *build_image_definition_dh
+ <<: *only_tag_release
+ variables:
+ <<: *extended_image_vars_dh
+ PG_SERVER_VERSION: "15"
+ TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_TAG}"
+
+build-extended-postgres-16-image-latest:
+ <<: *build_image_definition_dh
+ <<: *only_tag_release
+ variables:
+ <<: *extended_image_vars_dh
+ PG_SERVER_VERSION: "16"
+ TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_TAG}"
+
+build-extended-postgres-17-image-latest:
+ <<: *build_image_definition_dh
+ <<: *only_tag_release
+ variables:
+ <<: *extended_image_vars_dh
+ PG_SERVER_VERSION: "17"
+ TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_TAG}"
+
build-extended-postgres-9-6-image-feature:
<<: *build_image_definition_gl
<<: *only_feature
@@ -141,3 +165,27 @@ build-extended-postgres-14-image-feature:
<<: *extended_image_vars_gl
PG_SERVER_VERSION: "14"
TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_REF_SLUG}"
+
+build-extended-postgres-15-image-feature:
+ <<: *build_image_definition_gl
+ <<: *only_feature
+ variables:
+ <<: *extended_image_vars_gl
+ PG_SERVER_VERSION: "15"
+ TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_REF_SLUG}"
+
+build-extended-postgres-16-image-feature:
+ <<: *build_image_definition_gl
+ <<: *only_feature
+ variables:
+ <<: *extended_image_vars_gl
+ PG_SERVER_VERSION: "16"
+ TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_REF_SLUG}"
+
+build-extended-postgres-17-image-feature:
+ <<: *build_image_definition_gl
+ <<: *only_feature
+ variables:
+ <<: *extended_image_vars_gl
+ PG_SERVER_VERSION: "17"
+ TAGS: "${DOCKER_NAME}:${PG_SERVER_VERSION},${DOCKER_NAME}:${PG_SERVER_VERSION}-${CI_COMMIT_REF_SLUG}"
diff --git a/extended-postgres/test-images-ci.yml b/extended-postgres/test-images-ci.yml
new file mode 100644
index 0000000..077a75a
--- /dev/null
+++ b/extended-postgres/test-images-ci.yml
@@ -0,0 +1,200 @@
+stages:
+ - test-image
+
+.job_template: &test_image_definition
+ image: docker:24.0.6
+ stage: test-image
+ services:
+ - alias: docker
+ name: docker:24.0.6-dind
+ script:
+ - apk add --no-cache bash
+ - chmod +x extended-postgres/test/images_test.sh
+ - TAG=${TAG} PG_IMAGE_NAME="${DOCKER_NAME}" PG_SERVER_VERSION=${PG_SERVER_VERSION} CREATE_EXTENSION_EXCLUDE=${CREATE_EXTENSION_EXCLUDE} bash extended-postgres/test/images_test.sh
+
+.only_tag_template: &only_release
+ rules:
+ - if: $CI_COMMIT_TAG =~ /^[0-9.]+$/ || $COMMIT_TAG =~ /^[0-9.]+$/
+ when: always
+
+.release_vars:
+ variables: &release_vars
+ TAG: $CI_COMMIT_TAG
+ DOCKER_NAME: "postgresai/extended-postgres"
+
+.only_branch_template: &only_branch
+ rules:
+ - if: $CI_COMMIT_TAG =~ /^[0-9.]+$/ || $COMMIT_TAG =~ /^[0-9.]+$/
+ when: never
+ - if: $CI_COMMIT_BRANCH && $CI_COMMIT_REF_SLUG != "master"
+ when: manual
+
+.branch_vars:
+ variables: &branch_vars
+ TAG: $CI_COMMIT_REF_SLUG
+ DOCKER_NAME: "${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}/extended-postgres"
+
+test-extended-postgres-9-6-image-latest:
+ <<: *test_image_definition
+ <<: *only_release
+ dependencies:
+ - build-extended-postgres-9-6-image-latest
+ variables:
+ <<: *release_vars
+ PG_SERVER_VERSION: "9.6"
+ CREATE_EXTENSION_EXCLUDE: "pg_cron"
+
+test-extended-postgres-10-image-latest:
+ <<: *test_image_definition
+ <<: *only_release
+ dependencies:
+ - build-extended-postgres-10-image-latest
+ variables:
+ <<: *release_vars
+ PG_SERVER_VERSION: "10"
+
+test-extended-postgres-11-image-latest:
+ <<: *test_image_definition
+ <<: *only_release
+ dependencies:
+ - build-extended-postgres-11-image-latest
+ variables:
+ <<: *release_vars
+ PG_SERVER_VERSION: "11"
+
+test-extended-postgres-12-image-latest:
+ <<: *test_image_definition
+ <<: *only_release
+ dependencies:
+ - build-extended-postgres-12-image-latest
+ variables:
+ <<: *release_vars
+ PG_SERVER_VERSION: "12"
+
+test-extended-postgres-13-image-latest:
+ <<: *test_image_definition
+ <<: *only_release
+ dependencies:
+ - build-extended-postgres-13-image-latest
+ variables:
+ <<: *release_vars
+ PG_SERVER_VERSION: "13"
+
+test-extended-postgres-14-image-latest:
+ <<: *test_image_definition
+ <<: *only_release
+ dependencies:
+ - build-extended-postgres-14-image-latest
+ variables:
+ <<: *release_vars
+ PG_SERVER_VERSION: "14"
+
+test-extended-postgres-15-image-latest:
+ <<: *test_image_definition
+ <<: *only_release
+ dependencies:
+ - build-extended-postgres-15-image-latest
+ variables:
+ <<: *release_vars
+ PG_SERVER_VERSION: "15"
+
+test-extended-postgres-16-image-latest:
+ <<: *test_image_definition
+ <<: *only_release
+ dependencies:
+ - build-extended-postgres-16-image-latest
+ variables:
+ <<: *release_vars
+ PG_SERVER_VERSION: "16"
+
+test-extended-postgres-17-image-latest:
+ <<: *test_image_definition
+ <<: *only_release
+ dependencies:
+ - build-extended-postgres-17-image-latest
+ variables:
+ <<: *release_vars
+ PG_SERVER_VERSION: "17"
+
+
+test-extended-postgres-9-6-image-feature:
+ <<: *test_image_definition
+ <<: *only_branch
+ dependencies:
+ - build-extended-postgres-9-6-image-feature
+ variables:
+ <<: *branch_vars
+ PG_SERVER_VERSION: "9.6"
+ CREATE_EXTENSION_EXCLUDE: "pg_cron"
+
+test-extended-postgres-10-image-feature:
+ <<: *test_image_definition
+ <<: *only_branch
+ dependencies:
+ - build-extended-postgres-10-image-feature
+ variables:
+ <<: *branch_vars
+ PG_SERVER_VERSION: "10"
+
+test-extended-postgres-11-image-feature:
+ <<: *test_image_definition
+ <<: *only_branch
+ dependencies:
+ - build-extended-postgres-11-image-feature
+ variables:
+ <<: *branch_vars
+ PG_SERVER_VERSION: "11"
+
+test-extended-postgres-12-image-feature:
+ <<: *test_image_definition
+ <<: *only_branch
+ dependencies:
+ - build-extended-postgres-12-image-feature
+ variables:
+ <<: *branch_vars
+ PG_SERVER_VERSION: "12"
+
+test-extended-postgres-13-image-feature:
+ <<: *test_image_definition
+ <<: *only_branch
+ dependencies:
+ - build-extended-postgres-13-image-feature
+ variables:
+ <<: *branch_vars
+ PG_SERVER_VERSION: "13"
+
+test-extended-postgres-14-image-feature:
+ <<: *test_image_definition
+ <<: *only_branch
+ dependencies:
+ - build-extended-postgres-14-image-feature
+ variables:
+ <<: *branch_vars
+ PG_SERVER_VERSION: "14"
+
+test-extended-postgres-15-image-feature:
+ <<: *test_image_definition
+ <<: *only_branch
+ dependencies:
+ - build-extended-postgres-15-image-feature
+ variables:
+ <<: *branch_vars
+ PG_SERVER_VERSION: "15"
+
+test-extended-postgres-16-image-feature:
+ <<: *test_image_definition
+ <<: *only_branch
+ dependencies:
+ - build-extended-postgres-16-image-feature
+ variables:
+ <<: *branch_vars
+ PG_SERVER_VERSION: "16"
+
+test-extended-postgres-17-image-feature:
+ <<: *test_image_definition
+ <<: *only_branch
+ dependencies:
+ - build-extended-postgres-17-image-feature
+ variables:
+ <<: *branch_vars
+ PG_SERVER_VERSION: "17"
diff --git a/extended-postgres/test/images_test.sh b/extended-postgres/test/images_test.sh
new file mode 100644
index 0000000..819ba27
--- /dev/null
+++ b/extended-postgres/test/images_test.sh
@@ -0,0 +1,180 @@
+#!/bin/bash
+set -euxo pipefail
+
+# 1. Initializes the database using the base Postgres image and also performs some additional actions,
+# such as creating a test_contrib_extensions table and copying the list of available extensions into the Docker container.
+# 2. Modifies the postgresql.conf configuration file to load certain preloaded libraries.
+# 3. Starts PostgreSQL and creates a test_contrib_extensions table for testing.
+# 4. Runs tests which create all available extensions not included in the test_contrib_extensions table.
+# 5. At the end of the tests, it stops PostgreSQL and deletes the test data.
+#
+# USAGE (example):
+# TAG="0.5.0" PG_SERVER_VERSION="16" ./se_images_test.sh
+#
+## (optional) With a list of extensions (separated by commas) to exclude from the create extension test:
+# TAG="0.5.0" PG_SERVER_VERSION="10" CREATE_EXTENSION_EXCLUDE="pg_cron" ./se_images_test.sh
+
+# list of extensions (separated by commas) to exclude from the create extension test
+CREATE_EXTENSION_EXCLUDE=${CREATE_EXTENSION_EXCLUDE:-}
+if [[ -n "$CREATE_EXTENSION_EXCLUDE" ]]; then
+ IFS=',' read -ra NAMES <<< "$CREATE_EXTENSION_EXCLUDE"
+ formatted_exclusions=$(printf ", '%s'" "${NAMES[@]}")
+ formatted_exclusions=${formatted_exclusions:2}
+ exclude_condition="and name not in (${formatted_exclusions})"
+else
+ exclude_condition=""
+fi
+
+# list of extensions (separated by commas) to exclude from the compare extensions test
+COMPARE_EXTENSION_EXCLUDE=${COMPARE_EXTENSION_EXCLUDE:-}
+formatted_exclusions_compare=""
+
+if [[ -n "$COMPARE_EXTENSION_EXCLUDE" ]]; then
+ IFS=',' read -ra NAMES <<< "$COMPARE_EXTENSION_EXCLUDE"
+ formatted_exclusions_compare=$(printf ", '%s'" "${NAMES[@]}")
+ formatted_exclusions_compare=${formatted_exclusions_compare:2}
+fi
+
+if [[ -n "$formatted_exclusions_compare" ]]; then
+ exclude_condition_compare="and name not in (${formatted_exclusions_compare})"
+else
+ exclude_condition_compare=""
+fi
+
+TAG=${TAG:-${CI_COMMIT_REF_SLUG:-"master"}}
+PG_IMAGE_NAME="${PG_IMAGE_NAME:-'postgresai/extended-postgres'}"
+PG_SERVER_VERSION=${PG_SERVER_VERSION//,/ }
+PG_CONTAINER_NAME="postgres-${PG_SERVER_VERSION}"
+
+# initdb using the base image
+TEST_DIR="/tmp/test_image/${PG_CONTAINER_NAME}"
+TEST_PGDATA="${TEST_DIR}/data"
+
+rm -rf "${TEST_PGDATA}" && mkdir -p "${TEST_PGDATA}"
+
+docker stop "${PG_CONTAINER_NAME}" >/dev/null 2>&1 || true
+docker run -d --rm --name "${PG_CONTAINER_NAME}" \
+ -e PGDATA=/var/lib/postgresql/pgdata \
+ -e POSTGRES_HOST_AUTH_METHOD=trust \
+ -v "${TEST_PGDATA}":/var/lib/postgresql/pgdata \
+postgres:"${PG_SERVER_VERSION}"-bullseye >/dev/null 2>&1
+
+postgres_readiness(){
+ docker exec "${PG_CONTAINER_NAME}" \
+ psql -U postgres -c 'select 1' > /dev/null 2>&1
+ return $?
+}
+
+check_postgres_readiness(){
+ for i in {1..30}; do
+ postgres_readiness && break || echo "database is not ready yet"
+ sleep 4
+ done
+}
+
+check_postgres_readiness
+
+# Restart container explicitly after initdb
+# to make sure that the server will not receive a shutdown request and queries will not be interrupted.
+docker restart "${PG_CONTAINER_NAME}"
+
+check_postgres_readiness
+
+# export pg_available_extensions from base Postgres image
+docker exec "${PG_CONTAINER_NAME}" \
+ psql -U postgres -c \
+ "copy (select * from pg_available_extensions) to stdout with csv header delimiter ',';" \
+ > "${TEST_DIR}/available_extensions_${PG_SERVER_VERSION}.csv"
+
+# stop postgres after initdb
+docker stop "${PG_CONTAINER_NAME}" >/dev/null 2>&1
+
+# configure postgresql.conf
+CLEANED_PG_SERVER_VERSION=$(echo "$PG_SERVER_VERSION" | sed 's/rc.*//')
+BASE_LIBRARIES="pg_stat_statements,pg_stat_kcache,pg_cron,pgaudit,bg_mon"
+if [ "$(echo "$CLEANED_PG_SERVER_VERSION >= 12" | /usr/bin/bc)" = "1" ]; then
+ SHARED_PRELOAD_LIBRARIES="citus,timescaledb,anon,${BASE_LIBRARIES}"
+elif [ "$(echo "$CLEANED_PG_SERVER_VERSION == 11" | /usr/bin/bc)" = "1" ]; then
+ SHARED_PRELOAD_LIBRARIES="citus,anon,${BASE_LIBRARIES}"
+elif [ "$(echo "$CLEANED_PG_SERVER_VERSION == 10" | /usr/bin/bc)" = "1" ]; then
+ SHARED_PRELOAD_LIBRARIES="anon,${BASE_LIBRARIES}"
+else
+ SHARED_PRELOAD_LIBRARIES="${BASE_LIBRARIES}"
+fi
+
+# pull docker image
+docker pull "${PG_IMAGE_NAME}":"${PG_SERVER_VERSION}"-"${TAG}"
+
+# docker image size
+docker images --filter=reference="${PG_IMAGE_NAME}:${PG_SERVER_VERSION}-${TAG}"
+
+# start postgres and create test_contrib_extensions table for test
+docker run -d --rm --name "${PG_CONTAINER_NAME}" \
+ -e PGDATA=/var/lib/postgresql/pgdata \
+ -v "${TEST_PGDATA}":/var/lib/postgresql/pgdata \
+ --shm-size=1gb \
+ "${PG_IMAGE_NAME}":"${PG_SERVER_VERSION}"-"${TAG}" >/dev/null 2>&1
+
+docker cp "${TEST_DIR}/available_extensions_${PG_SERVER_VERSION}.csv" "${PG_CONTAINER_NAME}":/tmp/
+
+# shared_preload_libraries
+docker exec "${PG_CONTAINER_NAME}" \
+ bash -c "echo \"shared_preload_libraries = '${SHARED_PRELOAD_LIBRARIES}'\" >> /var/lib/postgresql/pgdata/postgresql.conf"
+
+# cron.database_name
+docker exec "${PG_CONTAINER_NAME}" \
+ bash -c "echo \"cron.database_name = 'postgres'\" >> /var/lib/postgresql/pgdata/postgresql.conf"
+
+docker restart "${PG_CONTAINER_NAME}"
+
+# debug
+docker logs "${PG_CONTAINER_NAME}"
+
+check_postgres_readiness
+
+docker exec "${PG_CONTAINER_NAME}" \
+ psql -U postgres -c "create table test_contrib_extensions (like pg_available_extensions)"
+
+docker exec "${PG_CONTAINER_NAME}" \
+ psql -U postgres -c \
+ "\copy test_contrib_extensions
+ from '/tmp/available_extensions_${PG_SERVER_VERSION}.csv' delimiter ',' csv header"
+
+# list of available (non-contrib) extensions
+docker exec "${PG_CONTAINER_NAME}" \
+ psql -U postgres -c "
+ select name, default_version, comment
+ from pg_available_extensions
+ where name not in (select name from test_contrib_extensions)
+ order by 1"
+
+# run test - create (non-contrib) extensions
+set +x # disable loop command output
+for extension in $(
+ docker exec "${PG_CONTAINER_NAME}" \
+ psql -U postgres -tAXc "
+ select name
+ from pg_available_extensions
+ where
+ name not in (select name from test_contrib_extensions)
+ ${exclude_condition}
+ order by 1"
+); do
+ echo "create extension \"$extension\""
+ docker exec "${PG_CONTAINER_NAME}" \
+ psql -U postgres -c "CREATE EXTENSION IF NOT EXISTS \"$extension\" CASCADE"
+done
+
+set -x # enable command output again
+
+# list of installed extensions
+docker exec "${PG_CONTAINER_NAME}" \
+ psql -U postgres -c "\dx"
+
+# stop postgres after test
+docker stop "${PG_CONTAINER_NAME}"
+rm -rf "${TEST_PGDATA}"
+
+# remove docker image after test
+docker rmi "${PG_IMAGE_NAME}":"${PG_SERVER_VERSION}"-"${TAG}" >/dev/null 2>&1 || true
+docker rmi postgres:"${PG_SERVER_VERSION}"-bullseye >/dev/null 2>&1 || true
diff --git a/migration-tools/build-images-migration-tools.yml b/migration-tools/build-images-migration-tools.yml
index ba832a8..616dedf 100644
--- a/migration-tools/build-images-migration-tools.yml
+++ b/migration-tools/build-images-migration-tools.yml
@@ -2,11 +2,11 @@ stages:
- build-image
.job_template: &build_image_definition_dh
- image: docker:19
+ image: docker:24.0.6
stage: build-image
services:
- alias: docker
- name: docker:19.03.5-dind
+ name: docker:24.0.6-dind
script:
- apk add --no-cache bash
- bash ./ci_docker_build_push.sh
@@ -17,11 +17,11 @@ stages:
DOCKER_NAME: "postgresai/migration-tools"
.job_template: &build_image_definition_gl
- image: docker:19
+ image: docker:24.0.6
stage: build-image
services:
- alias: docker
- name: docker:19.03.5-dind
+ name: docker:24.0.6-dind
script:
- apk add --no-cache bash
- bash ./ci_docker_build_push.sh