From b607ba5bfdf83c04e25c35dcbb943c680904ed7d Mon Sep 17 00:00:00 2001 From: "David E. Wheeler" Date: Mon, 5 Oct 2026 16:21:25 -0400 Subject: [PATCH] Add CloudNativePG OCI images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CloudNativePG mounts OCI images structured with extension files as read-only volumes and can be configured to use the extension from that location. Add `dist/cnpg.Dockerfile` with the recipe to create such an image for pg_clickhouse. It copies the patterns for the [CNPG PostGIS Dockerfile] to copy not only the extension files, but also libraries it depends on to run, installed via `apt-get`. It varies from the existing `Dockerfile` to be based on the CNPG minimal image, rather than the Docker Hub Postgres image. Move the existing `Dockerfile` and `docker-bake.hcl` into the new `dist` directory, to avoid crapping up the root with files intended to build packages. Add the "cnpg" target to `docker-bake.hcl` to handle Building `cnpg-pg_clickhouse` in a single `docker bake` (or `make image`) command. Rename the "default" target to "pg_clickhouse" and create a "group" that contains both "pg_clickhouse" and, when building for Postgres 18 or higher, the "cnpg" targets. Also add an `os_name` config and set it to "trixie" so it wil be straightforward to upgrade versions in the future. The resulting `cnpg-pg_clickhouse` images contain these files: ```console ❯ cek ls localhost:5001/cnpg-pg_clickhouse:18 | grep -v '/$' Mode Size Path -rw-r--r-- 56.5 KB /lib/bitcode/pg_clickhouse.index.bc -rw-r--r-- 203.9 KB /lib/bitcode/pg_clickhouse/src/binary/binary.bc -rw-r--r-- 15.3 KB /lib/bitcode/pg_clickhouse/src/binary/connection.bc -rw-r--r-- 11.1 KB /lib/bitcode/pg_clickhouse/src/binary/insert.bc -rw-r--r-- 9.9 KB /lib/bitcode/pg_clickhouse/src/binary/select.bc -rw-r--r-- 10.3 KB /lib/bitcode/pg_clickhouse/src/connection.bc -rw-r--r-- 8.7 KB /lib/bitcode/pg_clickhouse/src/cursor.bc -rw-r--r-- 28.3 KB /lib/bitcode/pg_clickhouse/src/custom_types.bc -rw-r--r-- 98.7 KB /lib/bitcode/pg_clickhouse/src/deparse.bc -rw-r--r-- 3.3 KB /lib/bitcode/pg_clickhouse/src/endpoint.bc -rw-r--r-- 41.0 KB /lib/bitcode/pg_clickhouse/src/fdw.bc -rw-r--r-- 18.9 KB /lib/bitcode/pg_clickhouse/src/http.bc -rw-r--r-- 6.5 KB /lib/bitcode/pg_clickhouse/src/kv_list.bc -rw-r--r-- 18.5 KB /lib/bitcode/pg_clickhouse/src/option.bc -rw-r--r-- 36.4 KB /lib/bitcode/pg_clickhouse/src/pglink.bc -rw-r--r-- 8.2 KB /lib/bitcode/pg_clickhouse/src/shipable.bc -rwxr-xr-x 1.6 MB /lib/pg_clickhouse.so -rw-r--r-- 1.3 KB /licenses/libbrotli1/copyright -rw-r--r-- 21.6 KB /licenses/libcurl4t64/copyright -rw-r--r-- 6.4 KB /licenses/libnghttp2-14/copyright -rw-r--r-- 8.4 KB /licenses/libnghttp3-9/copyright -rw-r--r-- 3.2 KB /licenses/libpsl5t64/copyright -rw-r--r-- 2.7 KB /licenses/librtmp1/copyright -rw-r--r-- 2.9 KB /licenses/libssh2-1t64/copyright -rw-r--r-- 10.3 KB /licenses/postgresql-18-pg_clickhouse-0.11.0/copyright -rw-r--r-- 84 B /share/extension/pg_clickhouse--0.1--0.2.sql -rw-r--r-- 107 B /share/extension/pg_clickhouse--0.10--0.11.sql -rw-r--r-- 7.0 KB /share/extension/pg_clickhouse--0.11.sql -rw-r--r-- 73 B /share/extension/pg_clickhouse--0.2--0.3.sql -rw-r--r-- 1.1 KB /share/extension/pg_clickhouse--0.3--0.10.sql -rw-r--r-- 147 B /share/extension/pg_clickhouse.control lrwxrwxrwx 0 B /system/libbrotlicommon.so -> libbrotlicommon.so.1.1.0 lrwxrwxrwx 0 B /system/libbrotlicommon.so.1 -> libbrotlicommon.so.1.1.0 -rw-r--r-- 194.2 KB /system/libbrotlicommon.so.1.1.0 lrwxrwxrwx 0 B /system/libbrotlidec.so -> libbrotlidec.so.1.1.0 lrwxrwxrwx 0 B /system/libbrotlidec.so.1 -> libbrotlidec.so.1.1.0 -rw-r--r-- 66.2 KB /system/libbrotlidec.so.1.1.0 lrwxrwxrwx 0 B /system/libcurl.so -> libcurl.so.4.8.0 lrwxrwxrwx 0 B /system/libcurl.so.4 -> libcurl.so.4.8.0 -rw-r--r-- 964.7 KB /system/libcurl.so.4.8.0 lrwxrwxrwx 0 B /system/libnghttp2.so -> libnghttp2.so.14.28.3 lrwxrwxrwx 0 B /system/libnghttp2.so.14 -> libnghttp2.so.14.28.3 -rw-r--r-- 194.5 KB /system/libnghttp2.so.14.28.3 lrwxrwxrwx 0 B /system/libnghttp3.so -> libnghttp3.so.9.2.6 lrwxrwxrwx 0 B /system/libnghttp3.so.9 -> libnghttp3.so.9.2.6 -rw-r--r-- 201.3 KB /system/libnghttp3.so.9.2.6 lrwxrwxrwx 0 B /system/libpsl.so -> libpsl.so.5.3.4 lrwxrwxrwx 0 B /system/libpsl.so.5 -> libpsl.so.5.3.4 -rw-r--r-- 129.9 KB /system/libpsl.so.5.3.4 lrwxrwxrwx 0 B /system/librtmp.so -> librtmp.so.1 -rw-r--r-- 131.4 KB /system/librtmp.so.1 lrwxrwxrwx 0 B /system/libssh2.so -> libssh2.so.1.0.1 lrwxrwxrwx 0 B /system/libssh2.so.1 -> libssh2.so.1.0.1 -rw-r--r-- 322.5 KB /system/libssh2.so.1.0.1 ``` Document the extension image in the `README`. While at it, add a Postgres 19 image and update GitHub action versions. [CNPG PostGIS Dockerfile]: https://github.com/cloudnative-pg/postgres-extensions-containers/blob/main/postgis/Dockerfile --- .github/workflows/bake.yml | 7 +- .github/workflows/clickhouse.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/postgres.yml | 2 +- .github/workflows/release.yml | 4 +- CHANGELOG.md | 10 +++ Makefile | 6 +- README.md | 43 +++++++++ dist/cnpg.Dockerfile | 76 ++++++++++++++++ dist/docker-bake.hcl | 145 +++++++++++++++++++++++++++++++ Dockerfile => dist/pg.Dockerfile | 15 ++-- docker-bake.hcl | 70 --------------- 12 files changed, 295 insertions(+), 87 deletions(-) create mode 100644 dist/cnpg.Dockerfile create mode 100644 dist/docker-bake.hcl rename Dockerfile => dist/pg.Dockerfile (74%) delete mode 100644 docker-bake.hcl diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index 06bb5fa6..9fea3928 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -16,15 +16,15 @@ jobs: strategy: fail-fast: false matrix: - pgv: [18, 17, 16, 15, 14] + pgv: [19, 18, 17, 16, 15, 14] steps: - name: Checkout the Repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: { submodules: recursive } - name: Set up Depot CLI uses: depot/setup-action@v1 - name: Log in to GHCR - uses: docker/login-action@v3 + uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} @@ -34,6 +34,7 @@ jobs: - name: Build${{ startsWith(github.ref, 'refs/tags') && ' and Push' || '' }} uses: depot/bake-action@v1 with: + files: dist/docker-bake.hcl project: vrpfjb99c5 platforms: linux/amd64,linux/arm64 pull: true diff --git a/.github/workflows/clickhouse.yml b/.github/workflows/clickhouse.yml index 7f0b4e20..d84831cc 100644 --- a/.github/workflows/clickhouse.yml +++ b/.github/workflows/clickhouse.yml @@ -36,7 +36,7 @@ jobs: - name: Install Extensions run: pgxn install re2 - name: Checkout the Repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: { submodules: recursive } - name: Start ClickHouse env: { CH_RELEASE: "${{ matrix.ch }}" } diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ffb0fe9f..9d945ca1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ jobs: - name: Install Postgres run: NO_CLUSTER=1 pg-start ${{ env.pg }} libcurl4-openssl-dev uuid-dev liblz4-dev libzstd-dev clang-tidy bear shellcheck - name: Checkout the Repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: { submodules: recursive } - name: Install pre-commit run: make debian-install-lint diff --git a/.github/workflows/postgres.yml b/.github/workflows/postgres.yml index 649a0611..2021b496 100644 --- a/.github/workflows/postgres.yml +++ b/.github/workflows/postgres.yml @@ -26,7 +26,7 @@ jobs: - name: Install Extensions run: pgxn install re2 - name: Checkout the Repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: { submodules: recursive } - name: Start ClickHouse run: .github/ubuntu/clickhouse.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5fde686a..9330138d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: container: pgxn/pgxn-tools steps: - name: Check out the repo - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Start Postgres run: pg-start 19 libcurl4-openssl-dev uuid-dev liblz4-dev libzstd-dev - name: Start ClickHouse @@ -38,7 +38,7 @@ jobs: if: startsWith( github.ref, 'refs/tags/v' ) - name: Create GitHub Release if: startsWith( github.ref, 'refs/tags/v' ) - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@v3 with: name: "Release ${{ github.ref_name }}" body_path: "${{ steps.notes.outputs.file }}" diff --git a/CHANGELOG.md b/CHANGELOG.md index dcba12d9..f13d3d0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ All notable changes to this project will be documented in this file. It uses the [Semantic Versioning]: https://semver.org/spec/v2.0.0.html "Semantic Versioning 2.0.0" +## [v0.11.1] — Unreleased + +### 🚀 Distribution + +* Added Postgres 19beta4 image. +* Added [CloudNativePG] extension images. + + [v0.11.1]: https://github.com/ClickHouse/pg_clickhouse/compare/v0.11.0...v0.11.1 + [CloudNativePG]: https://cloudnative-pg.io/ "Run PostgreSQL The Kubernetes way" + ## [v0.11.0] — 2026-09-30 This release makes binary-compatible changes to the v0.10 releases. Once diff --git a/Makefile b/Makefile index fe837833..caeefe13 100644 --- a/Makefile +++ b/Makefile @@ -125,13 +125,13 @@ print-% : ; $(info $* is $(flavor $*) variable set to "$($*)") @true REGISTRY ?= localhost:5001 REVISION := $(shell git rev-parse --short HEAD) PLATFORMS ?= linux/amd64,linux/arm64 -PG_VERSIONS ?= 18,17,16,15,14 +PG_VERSIONS ?= 19,18,17,16,15,14 .PHONY: image # Build the linux/amd64 OCI image. image: registry=$(REGISTRY) version=$(DISTVERSION) revision=$(REVISION) pg_versions=$(PG_VERSIONS) \ - docker buildx bake --set "*.platform=$(PLATFORMS)" \ + docker buildx bake --file dist/docker-bake.hcl --set "*.platform=$(PLATFORMS)" \ $(if $(filter true,$(PUSH)),--push,) \ - $(if $(filter true,$(LOAD)),--load,) \ + $(if $(filter true,$(LOAD)),--load,) bake-vars: @echo "registry=$(REGISTRY)" diff --git a/README.md b/README.md index b33db856..3bd3f9b3 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,8 @@ with 36 GB of memory. | [Query 21] | 1145 ms | 4470 ms | | | [Query 22] | 270 ms | 45 ms | ✼ | +## Installation + ### Compile From Source #### General Unix @@ -209,6 +211,42 @@ You need to run the test suite using a super user, such as the default make installcheck PGUSER=postgres ``` +### CloudNativePG + +Add pg_clickhouse to a [CloudNativePG] cluster using [ExtensionConfiguration]: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: cluster-example +spec: + # ... + postgresql: + # ExtensionConfiguration + extensions: + - name: pg_clickhouse + image: + reference: ghcr.io/ClickHouse/cnpg-pg_clickhouse:{pg_major_version}-{pg_clickhouse_version} +``` + +To load it into a database, use [ExtensionSpec]: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Database +metadata: + name: pg_clickhouse-cluster +spec: + name: app + owner: app + cluster: + name: pg_clickhouse-cluster + extensions: + - name: pg_clickhouse + version: {pg_clickhouse_version} +``` + ### Loading Once `pg_clickhouse` is installed, you can add it to a database by connecting @@ -292,6 +330,11 @@ adding DML features. Our road map: [LibSSL]: https://openssl-library.org "OpenSSL Library" [TPC-H]: https://www.tpc.org/tpch/ [re2]: https://github.com/ClickHouse/pg_re2 "pg_re2: ClickHouse-compatible regex functions using RE2" + [CloudNativePG]: https://cloudnative-pg.io/ "Run PostgreSQL The Kubernetes way" + [ExtensionConfiguration]: https://cloudnative-pg.io/docs/devel/cloudnative-pg.v1#extensionconfiguration + "CloudNativePG Docs: ExtensionConfiguration: + [ExtensionSpec]: https://cloudnative-pg.io/docs/devel/cloudnative-pg.v1#extensionspec + "CloudNativePG Docs: ExtensionSpec: [Query 1]: https://github.com/ClickHouse/pg_clickhouse/blob/main/dev/tpch/queries/1.sql [Query 2]: https://github.com/ClickHouse/pg_clickhouse/blob/main/dev/tpch/queries/2.sql diff --git a/dist/cnpg.Dockerfile b/dist/cnpg.Dockerfile new file mode 100644 index 00000000..29f9e29c --- /dev/null +++ b/dist/cnpg.Dockerfile @@ -0,0 +1,76 @@ +ARG PG_MAJOR=19 +ARG BASE=postgres + +FROM $BASE AS builder +ARG PG_MAJOR + +USER 0 + +WORKDIR /work +COPY . . +RUN set -eux && \ + # Initial system libraries + ldconfig -p | awk '{print $NF}' | grep '^/' | sort | uniq > /tmp/base-image-libs.out && \ + # Install Dependencies + apt-get update && apt-get install -y --no-install-recommends \ + postgresql-server-dev-$PG_MAJOR \ + libcurl4-openssl-dev \ + uuid-dev \ + make \ + libssl-dev \ + liblz4-dev \ + libzstd-dev \ + libicu-dev \ + g++ + +RUN make && make install DESTDIR=/dest + +# Gather dependent system libraries and their licenses; based on +# https://github.com/cloudnative-pg/postgres-extensions-containers/blob/main/postgis/Dockerfile +RUN mkdir -p /system /licenses && \ + # Get libraries + ldd /dest/usr/lib/postgresql/$PG_MAJOR/lib/pg_clickhouse*.so \ + | awk '{print $3}' | grep '^/' | sort | uniq > /tmp/all-deps.out && \ + # Extract all the libs that aren't already part of the base image + comm -13 /tmp/base-image-libs.out /tmp/all-deps.out > /tmp/libraries.out && \ + while read -r lib; do \ + resolved=$(readlink -f "$lib"); \ + dir=$(dirname "$lib"); \ + base=$(basename "$lib"); \ + # Copy the real file + cp -a "$resolved" /system/; \ + # Reconstruct all its symlinks + for file in "$dir"/"${base%.so*}.so"*; do \ + [ -e "$file" ] || continue; \ + # If it's a symlink and it resolves to the same real file, we reconstruct it + if [ -L "$file" ] && [ "$(readlink -f "$file")" = "$resolved" ]; then \ + ln -sf "$(basename "$resolved")" "/system/$(basename "$file")"; \ + fi; \ + done; \ + done < /tmp/libraries.out && \ + # Get licenses + for lib in $(find /system -maxdepth 1 -type f -name '*.so*'); do \ + # Get the name of the pkg that installed the library + pkg=$(dpkg -S "$(basename "$lib")" | grep -v "diversion by" | awk -F: '/:/{print $1; exit}'); \ + [ -z "$pkg" ] && continue; \ + mkdir -p "/licenses/$pkg" && cp -a "/usr/share/doc/$pkg/copyright" "/licenses/$pkg/copyright"; \ + done + +FROM scratch +ARG VERSION +ARG PG_MAJOR + +# Licenses +COPY --from=builder /licenses /licenses/ +COPY LICENSE.md /licenses/postgresql-$PG_MAJOR-pg_clickhouse-$VERSION/copyright + +# Libraries +COPY --from=builder /dest/usr/lib/postgresql/$PG_MAJOR/lib /lib + +# Share +COPY --from=builder /dest/usr/share/postgresql/$PG_MAJOR/extension /share/extension + +# System libs +COPY --from=builder /system /system/ + +USER 65532:65532 diff --git a/dist/docker-bake.hcl b/dist/docker-bake.hcl new file mode 100644 index 00000000..7de3ab4a --- /dev/null +++ b/dist/docker-bake.hcl @@ -0,0 +1,145 @@ +# Variables to be specified externally. +variable "registry" { + default = "ghcr.io/clickhouse" + description = "The image registry." +} + +variable "version" { + default = "" + description = "The release version." +} + +variable "revision" { + default = "" + description = "The current Git commit SHA." +} + +# Postgres versions to build. Pass comma-delimited list: pg_versions=18,16. +variable "pg_versions" { + type = list(number) + default = [19, 18, 17, 16, 15, 14] +} + +variable "os_name" { + default = "trixie" + description = "The name of the base Debian distribution." +} + +# Values to use in the targets. +now = timestamp() +authors = "David E. Wheeler" +url = "https://github.com/ClickHouse/pg_clickhouse" + +group "default" { + # Exclude cnpg if not building for Postgres 18 or higher. + targets = length([for v in pg_versions : v if v >= 18]) > 0 ? ["pg_clickhouse", "cnpg"] : ["pg_clickhouse"] +} + +target "pg_clickhouse" { + platforms = ["linux/amd64", "linux/arm64"] + matrix = { + pgv = pg_versions + } + name = "pg_clickhouse-${pgv}" + context = "." + dockerfile = "dist/pg.Dockerfile" + args = { + PG_MAJOR = "${pgv}" + BASE = "postgres:${base_version("${pgv}")}-${os_name}" + } + tags = [ + "${registry}/pg_clickhouse:${pgv}", + "${registry}/pg_clickhouse:${pgv}-${version}", + ] + annotations = [ + "index,manifest:org.opencontainers.image.created=${now}", + "index,manifest:org.opencontainers.image.url=${url}", + "index,manifest:org.opencontainers.image.source=${url}", + "index,manifest:org.opencontainers.image.version=${pgv}-${version}", + "index,manifest:org.opencontainers.image.revision=${revision}", + "index,manifest:org.opencontainers.image.vendor=${authors}", + "index,manifest:org.opencontainers.image.title=PostgreSQL ${pgv} with pg_clickhouse ${version}", + "index,manifest:org.opencontainers.image.description=PostgreSQL ${pgv} with pg_clickhouse ${version} on ${os_name}", + "index,manifest:org.opencontainers.image.documentation=${url}", + "index,manifest:org.opencontainers.image.authors=${authors}", + "index,manifest:org.opencontainers.image.licenses=PostgreSQL AND Apache-2.0", + "index,manifest:org.opencontainers.image.base.name=postgres", + ] + labels = { + "org.opencontainers.image.created" = "${now}", + "org.opencontainers.image.url" = "${url}", + "org.opencontainers.image.source" = "${url}", + "org.opencontainers.image.version" = "${pgv}-${version}", + "org.opencontainers.image.revision" = "${revision}", + "org.opencontainers.image.vendor" = "${authors}", + "org.opencontainers.image.title" = "PostgreSQL ${pgv} with pg_clickhouse ${version}", + "org.opencontainers.image.description" = "PostgreSQL ${pgv} with pg_clickhouse ${version} on ${os_name}", + "org.opencontainers.image.documentation" = "${url}", + "org.opencontainers.image.authors" = "${authors}", + "org.opencontainers.image.licenses" = "PostgreSQL AND Apache-2.0" + "org.opencontainers.image.base.name" = "postgres", + } +} + +target "cnpg" { + platforms = ["linux/amd64", "linux/arm64"] + matrix = { + pgv = [for v in pg_versions : v if v >= 18] + } + name = "cnpg-pg_clickhouse-${pgv}" + context = "." + tags = [ + "${registry}/cnpg-pg_clickhouse:${pgv}", + "${registry}/cnpg-pg_clickhouse:${pgv}-${version}", + ] + dockerfile = "dist/cnpg.Dockerfile" + args = { + PG_MAJOR = "${pgv}" + BASE = "ghcr.io/cloudnative-pg/postgresql:${base_version("${pgv}")}-minimal-${os_name}" + VERSION = "${version}" + } + annotations = [ + "index,manifest:org.opencontainers.image.created=${now}", + "index,manifest:org.opencontainers.image.url=${url}", + "index,manifest:org.opencontainers.image.source=${url}", + "index,manifest:org.opencontainers.image.version=${version}", + "index,manifest:org.opencontainers.image.revision=${revision}", + "index,manifest:org.opencontainers.image.vendor=${authors}", + "index,manifest:org.opencontainers.image.title=pg_clickhouse ${version} ${os_name}", + "index,manifest:org.opencontainers.image.description=pg_clickhouse ${version} container image for PostgreSQL ${pgv} on ${os_name}", + "index,manifest:org.opencontainers.image.documentation=${url}", + "index,manifest:org.opencontainers.image.authors=${authors}", + "index,manifest:org.opencontainers.image.licenses=PostgreSQL AND Apache-2.0", + "index,manifest:org.opencontainers.image.base.name=scratch", + "index,manifest:io.cloudnativepg.image.base.name=ghcr.io/cloudnative-pg/postgresql:${pgv}-minimal-${os_name}", + "index,manifest:io.cloudnativepg.image.base.os=${os_name}", + "index,manifest:io.cloudnativepg.image.base.pgmajor=${pgv}", + "index,manifest:io.cloudnativepg.image.sql.version=${version}", + ] + labels = { + "org.opencontainers.image.created" = "${now}", + "org.opencontainers.image.url" = "${url}", + "org.opencontainers.image.source" = "${url}", + "org.opencontainers.image.version" = "${version}", + "org.opencontainers.image.revision" = "${revision}", + "org.opencontainers.image.vendor" = "${authors}", + "org.opencontainers.image.title" = "pg_clickhouse ${version} ${os_name}", + "org.opencontainers.image.description" = "pg_clickhouse ${version} container image for PostgreSQL ${pgv} on ${os_name}", + "org.opencontainers.image.documentation" = "${url}", + "org.opencontainers.image.authors" = "${authors}", + "org.opencontainers.image.licenses" = "PostgreSQL AND Apache-2.0" + "org.opencontainers.image.base.name" = "scratch", + "io.cloudnativepg.image.base.name" = "ghcr.io/cloudnative-pg/postgresql:${pgv}-minimal-${os_name}", + "io.cloudnativepg.image.base.os" = "${os_name}", + "io.cloudnativepg.image.base.pgmajor" = "${pgv}", + "io.cloudnativepg.image.sql.version" = "${version}", + } +} + +# Determines the version string used in image tags. Required because beta +# versions have "betaX" in the version name, whereas final releases do not. +# Must be updated upon the release of 19.0 and the introduction of 20beta1. +function base_version { + params = [ pgv ] + result = pgv == 19 ? "${pgv}beta4" : pgv +} diff --git a/Dockerfile b/dist/pg.Dockerfile similarity index 74% rename from Dockerfile rename to dist/pg.Dockerfile index 007946da..8418e51d 100644 --- a/Dockerfile +++ b/dist/pg.Dockerfile @@ -1,6 +1,7 @@ ARG PG_MAJOR=19 +ARG BASE=postgres -FROM postgres:$PG_MAJOR-trixie AS build +FROM $BASE AS build WORKDIR /work COPY . . @@ -23,7 +24,9 @@ RUN make && make install DESTDIR=/dest # Build the latest stable version of the re2 extension. RUN cd /tmp && pgxn download re2 && unzip re2-*.zip && rm re2-*.zip && cd re2-* && make && make install DESTDIR=/dest -FROM postgres:$PG_MAJOR-trixie +############################################################################## +# Main image with Postgres, pg_clickhouse, and pg_re2. +FROM $BASE # Install dependencies RUN apt-get update && apt-get install -y --no-install-recommends libcurl4t64 uuid libre2-11 liblz4-1 libzstd1 ca-certificates \ @@ -32,18 +35,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends libcurl4t64 uui # Install extension files. COPY --chmod=644 --from=build \ + /dest/usr/share/postgresql/$PG_MAJOR/extension/*.* \ /dest/usr/share/postgresql/$PG_MAJOR/extension/*.* \ /usr/share/postgresql/$PG_MAJOR/extension/ # Install shared libraries. COPY --chmod=755 --from=build \ + /dest/usr/lib/postgresql/$PG_MAJOR/lib/*.so* \ /dest/usr/lib/postgresql/$PG_MAJOR/lib/*.so* \ /usr/lib/postgresql/$PG_MAJOR/lib/ # Install bitcode files. COPY --chmod=644 --from=build \ - /dest/usr/lib/postgresql/$PG_MAJOR/lib/bitcode/*.bc \ + /dest/usr/lib/postgresql/$PG_MAJOR/lib/bitcode/ \ + /dest/usr/lib/postgresql/$PG_MAJOR/lib/bitcode/ \ /usr/lib/postgresql/$PG_MAJOR/lib/bitcode/ -COPY --chmod=644 --from=build \ - /dest/usr/lib/postgresql/$PG_MAJOR/lib/bitcode/pg_clickhouse/src/*.bc \ - /usr/lib/postgresql/$PG_MAJOR/lib/bitcode/pg_clickhouse/src/ diff --git a/docker-bake.hcl b/docker-bake.hcl deleted file mode 100644 index 2552a602..00000000 --- a/docker-bake.hcl +++ /dev/null @@ -1,70 +0,0 @@ -# Variables to be specified externally. -variable "registry" { - default = "ghcr.io/clickhouse" - description = "The image registry." -} - -variable "version" { - default = "" - description = "The release version." -} - -variable "revision" { - default = "" - description = "The current Git commit SHA." -} - -# Postgres versions to build. Pass comma-delimited list: pg_versions=18,16. -variable "pg_versions" { - type = list(number) - default = [19, 18, 17, 16, 15, 14] -} - -# Values to use in the targets. -now = timestamp() -authors = "David E. Wheeler" -url = "https://github.com/ClickHouse/pg_clickhouse" - -target "default" { - platforms = ["linux/amd64", "linux/arm64"] - matrix = { - pgv = pg_versions - } - name = "pg_clickhouse-${pgv}" - context = "." - args = { - PG_MAJOR = "${pgv}" - } - tags = [ - "${registry}/pg_clickhouse:${pgv}", - "${registry}/pg_clickhouse:${pgv}-${version}", - ] - annotations = [ - "index,manifest:org.opencontainers.image.created=${now}", - "index,manifest:org.opencontainers.image.url=${url}", - "index,manifest:org.opencontainers.image.source=${url}", - "index,manifest:org.opencontainers.image.version=${pgv}-${version}", - "index,manifest:org.opencontainers.image.revision=${revision}", - "index,manifest:org.opencontainers.image.vendor=${authors}", - "index,manifest:org.opencontainers.image.title=PostgreSQL with pg_clickhouse", - "index,manifest:org.opencontainers.image.description=PostgreSQL ${pgv} with pg_clickhouse ${version}", - "index,manifest:org.opencontainers.image.documentation=${url}", - "index,manifest:org.opencontainers.image.authors=${authors}", - "index,manifest:org.opencontainers.image.licenses=PostgreSQL AND Apache-2.0", - "index,manifest:org.opencontainers.image.base.name=postgres", - ] - labels = { - "org.opencontainers.image.created" = "${now}", - "org.opencontainers.image.url" = "${url}", - "org.opencontainers.image.source" = "${url}", - "org.opencontainers.image.version" = "${pgv}-${version}", - "org.opencontainers.image.revision" = "${revision}", - "org.opencontainers.image.vendor" = "${authors}", - "org.opencontainers.image.title" = "PostgreSQL with pg_clickhouse", - "org.opencontainers.image.description" = "PostgreSQL ${pgv} with pg_clickhouse ${version}", - "org.opencontainers.image.documentation" = "${url}", - "org.opencontainers.image.authors" = "${authors}", - "org.opencontainers.image.licenses" = "PostgreSQL AND Apache-2.0" - "org.opencontainers.image.base.name" = "scratch", - } -}