From 99052d64396813d81dd2a4637c189a5de5910bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Fei?= Date: Fri, 4 Apr 2025 19:37:12 +0200 Subject: [PATCH 1/6] ci: move the container build process to bake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niccolò Fei --- Dockerfile | 89 +++++++++++++++++++++--------------------- build-deps.txt | 21 ++++++++++ docker-bake.hcl | 102 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 45 deletions(-) create mode 100644 docker-bake.hcl diff --git a/Dockerfile b/Dockerfile index 2d9d8ac..3066af9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,11 @@ -# vim:set ft=dockerfile: -# -# Copyright The CloudNativePG Contributors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -FROM debian:bookworm-slim +ARG BASE=debian:bookworm-slim + +FROM $BASE AS build-layer ARG PG_REPO=https://git.postgresql.org/git/postgresql.git ARG PG_BRANCH=master ARG PG_MAJOR=18 -# Do not split the description, otherwise we will see a blank space in the labels -LABEL name="PostgreSQL Container Images" \ - vendor="The CloudNativePG Contributors" \ - version="$PG_MAJOR-devel" \ - summary="PostgreSQL Container images." \ - description="This Docker image contains a snapshot image of PostgreSQL compiled from Master and Barman Cloud based on Debian bookworm-slim." - COPY build-deps.txt / # Install runtime and build dependencies @@ -38,19 +17,17 @@ RUN apt-get update && \ locales-all \ ssl-cert \ libnss-wrapper \ + libgssapi-krb5-2 \ libxml2 \ libllvm16 \ libxslt1.1 \ xz-utils \ zstd \ + postgresql-common \ $(cat /build-deps.txt) && \ rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* -# explicitly set user/group IDs -RUN groupadd -r postgres --gid=999 && \ - useradd -r -g postgres --uid=26 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres && \ - mkdir -p /var/lib/postgresql && \ - chown -R postgres:postgres /var/lib/postgresql +RUN usermod -u 26 postgres ENV PG_MAJOR=$PG_MAJOR ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin:$PATH @@ -112,6 +89,16 @@ RUN mkdir -p /usr/src/postgresql && \ make install-world-bin && \ rm -rf /usr/src/postgresql +# DoD 2.3 - remove setuid/setgid from any binary that not strictly requires it, and before doing that list them on the stdout +RUN find / -not -path "/proc/*" -perm /6000 -type f -exec ls -ld {} \; -exec chmod a-s {} \; || true + + +FROM build-layer AS minimal +RUN apt-get purge -y --auto-remove $(cat /build-deps.txt) && \ + rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* +USER 26 + +FROM build-layer AS standard # TODO: re-enable once https://github.com/pgaudit/pgaudit/issues/257 is fixed # Build PgAudit # See to https://github.com/pgaudit/pgaudit/blob/master/README.md#compile-and-install @@ -121,30 +108,42 @@ RUN mkdir -p /usr/src/postgresql && \ # make install USE_PGXS=1 PG_CONFIG=/usr/lib/postgresql/$PG_MAJOR/bin/pg_config && \ # rm -rf /usr/src/pgaudit -# Purge build dependencies -RUN apt-get purge -y --autoremove $(cat /build-deps.txt) - # Install barman-cloud -RUN key='B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8' && \ - export GNUPGHOME="$(mktemp -d)" && \ - mkdir -p /usr/local/share/keyrings/ && \ - gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" && \ - gpg --batch --export --armor "$key" > /usr/local/share/keyrings/postgres.gpg.asc && \ - gpgconf --kill all && \ - rm -rf "$GNUPGHOME" && \ - aptRepo="[ signed-by=/usr/local/share/keyrings/postgres.gpg.asc ] http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main $PG_MAJOR" && \ - echo "deb $aptRepo" > /etc/apt/sources.list.d/pgdg.list && \ - apt-get update && \ +RUN apt-get update && \ + /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && \ apt-get install -y --no-install-recommends \ python3-pip \ python3-psycopg2 \ python3-setuptools \ && \ pip3 install --break-system-packages --upgrade pip && \ - pip3 install --break-system-packages barman[cloud,azure,google,snappy,zstandard,lz4]==3.12.1 boto3==1.35.99 && \ + pip3 install --break-system-packages barman[cloud,azure,google,snappy,zstandard,lz4]==3.13.2 + +RUN apt-get purge -y --auto-remove $(cat /build-deps.txt) && \ rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* +USER 26 -# DoD 2.3 - remove setuid/setgid from any binary that not strictly requires it, and before doing that list them on the stdout -RUN find / -not -path "/proc/*" -perm /6000 -type f -exec ls -ld {} \; -exec chmod a-s {} \; || true +FROM build-layer AS postgis +ARG POSTGIS_REPO=https://github.com/postgis/postgis.git +ARG POSTGIS_BRANCH=master +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + libproj25 \ + libpq5 \ + libgdal32 \ + libgeos-c1v5 \ + libsfcgal1 \ + && \ + mkdir -p /usr/src/postgis && \ + git clone -b "$POSTGIS_BRANCH" --single-branch "$POSTGIS_REPO" /usr/src/postgis && \ + cd /usr/src/postgis && \ + ./autogen.sh && \ + ./configure --with-pgconfig=/usr/lib/postgresql/$PG_MAJOR/bin/pg_config --with-sfcgal && \ + make -j$(nproc) && \ + make install && \ + rm -rf /usr/src/postgis + +RUN apt-get purge -y --auto-remove $(cat /build-deps.txt) && \ + rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* USER 26 diff --git a/build-deps.txt b/build-deps.txt index 60ebbb2..04001e0 100644 --- a/build-deps.txt +++ b/build-deps.txt @@ -1,24 +1,45 @@ +autoconf +automake bison +libjson-c-dev build-essential clang-16 +cmake +docbook-xml +docbook5-xml flex gettext git +libboost-all-dev +libcunit1-dev +libcurl4-gnutls-dev libedit-dev +libgdal-dev +libgeos-dev +libgmp-dev libipc-run-perl libkrb5-dev libldap-dev liblz4-dev libpam0g-dev +libpcre3-dev libperl-dev +libproj-dev +libprotobuf-c-dev libreadline-dev libselinux1-dev +libsfcgal-dev +libsqlite3-dev libssl-dev libsystemd-dev +libtiff-dev +libtool +libxml2-utils libxslt1-dev libzstd-dev llvm-16-dev pkg-config +protobuf-c-compiler python3-dev systemtap-sdt-dev tcl-dev diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..7c603f0 --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,102 @@ +variable "environment" { + default = "testing" + validation { + condition = contains(["testing", "production"], environment) + error_message = "environment must be either testing or production" + } +} + +variable "registry" { + default = "localhost:5000" +} + +variable "insecure" { + default = "false" +} + +// Use the revision variable to identify the commit that generated the image +variable "revision" { + default = "1" +} + +fullname = ( environment == "testing") ? "${registry}/postgresql-trunk-testing" : "${registry}/postgresql-trunk" +now = timestamp() +title = "PostgreSQL Trunk Containers" +description = "PostgreSQL Trunk Containers for CloudNativePG operator" +authors = "The CloudNativePG Contributors" +url = "https://github.com/cloudnative-pg/postgres-trunk-containers" + +target "default" { + matrix = { + tgt = [ + "minimal", + "standard", + "postgis" + ] + pgMajor = ["18"] + base = ["debian:bookworm-slim"] + } + + platforms = [ + "linux/amd64" + ] + + dockerfile = "Dockerfile" + name = "postgresql-${pgMajor}-${tgt}-${distroVersion(base)}" + tags = [ + "${fullname}:${pgMajor}-${tgt}-${distroVersion(base)}", + "${fullname}:${pgMajor}-${formatdate("YYYYMMDDhhmm", now)}-${tgt}-${distroVersion(base)}" + ] + context = "." + target = "${tgt}" + args = { + PG_MAJOR = "${pgMajor}" + BASE = "${base}" + } + + output = [ + "type=image,registry.insecure=${insecure}", + ] + attest = [ + "type=provenance,mode=max", + "type=sbom" + ] + 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=${pgMajor}", + "index,manifest:org.opencontainers.image.revision=${revision}", + "index,manifest:org.opencontainers.image.vendor=${authors}", + "index,manifest:org.opencontainers.image.title=CloudNativePG PostgreSQL ${pgMajor} ${tgt}", + "index,manifest:org.opencontainers.image.description=A ${tgt} PostgreSQL ${pgMajor} container image", + "index,manifest:org.opencontainers.image.documentation=${url}", + "index,manifest:org.opencontainers.image.authors=${authors}", + "index,manifest:org.opencontainers.image.licenses=Apache-2.0", + "index,manifest:org.opencontainers.image.base.name=docker.io/library/${tag(base)}", + ] + labels = { + "org.opencontainers.image.created" = "${now}", + "org.opencontainers.image.url" = "${url}", + "org.opencontainers.image.source" = "${url}", + "org.opencontainers.image.version" = "${pgMajor}", + "org.opencontainers.image.revision" = "${revision}", + "org.opencontainers.image.vendor" = "${authors}", + "org.opencontainers.image.title" = "CloudNativePG PostgreSQL ${pgMajor} ${tgt}", + "org.opencontainers.image.description" = "A ${tgt} PostgreSQL ${pgMajor} container image", + "org.opencontainers.image.documentation" = "${url}", + "org.opencontainers.image.authors" = "${authors}", + "org.opencontainers.image.licenses" = "Apache-2.0" + "org.opencontainers.image.base.name" = "docker.io/library/debian:${tag(base)}" + } +} + +function tag { + params = [ imageName ] + result = index(split(":", imageName), 1) +} + +function distroVersion { + params = [ imageName ] + result = index(split("-", tag(imageName)), 0) +} From ca13f3f94e8aa8be3a9eb222ca986caa195c39e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Fei?= Date: Mon, 7 Apr 2025 15:40:45 +0200 Subject: [PATCH 2/6] ci: use bake in continuos-deliver.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niccolò Fei --- .github/workflows/continuous-delivery.yml | 34 ++++++++++++----------- defaults.json | 2 +- docker-bake.hcl | 8 ++++-- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 2cdc25e..20b09c1 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -14,10 +14,6 @@ on: schedule: - cron: '0 1 * * *' -# set up environment variables to be used across all the jobs -env: - REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk" - defaults: run: # default failure handling for shell scripts in 'run' steps @@ -31,7 +27,7 @@ jobs: contents: read packages: write outputs: - pg_image: ${{ env.TAG }} + pg_image: ${{ env.PG_IMAGE }} pg_major: ${{ env.PG_MAJOR }} cnpg_branch: ${{ env.CNPG_BRANCH }} test_depth: ${{ env.TEST_DEPTH }} @@ -59,11 +55,6 @@ jobs: echo "FEATURE_TYPE=${{ github.event.inputs.feature_type }}" >> $GITHUB_ENV fi - - name: Set tag - run: | - postgres_img="${{ env.REGISTRY }}:${{ env.PG_MAJOR }}-devel" - echo "TAG=${postgres_img}" >> $GITHUB_ENV - - name: Log in to the GitHub Container registry uses: docker/login-action@v3 with: @@ -71,14 +62,25 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and load - uses: docker/build-push-action@v6 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/bake-action@v6 + id: build + env: + environment: production + registry: ghcr.io/${{ github.repository_owner }} + revision: ${{ github.sha }} + pgMajor: ${{ env.PG_MAJOR }} with: - context: . push: true - load: false - tags: | - ${{ env.TAG }} + + # Get a list of the images that were built and pushed. We only care about a single tag for each image. + - name: Generated images + id: images + run: | + echo "PG_IMAGE=$(echo '${{ steps.build.outputs.metadata }}' | jq -c '.["standard"].["image.name"]' | grep -oP '[^,]*\d{12}[^,]*')" >> $GITHUB_ENV call-reusable-e2e: if: github.event_name == 'schedule' diff --git a/defaults.json b/defaults.json index 2036f27..67f09b3 100644 --- a/defaults.json +++ b/defaults.json @@ -1,5 +1,5 @@ { - "PG_IMAGE": "ghcr.io/cloudnative-pg/postgresql-trunk:18-devel", + "PG_IMAGE": "ghcr.io/cloudnative-pg/postgresql-trunk:18-standard-bookworm", "PG_MAJOR": 18, "CNPG_BRANCH": "main", "TEST_DEPTH": 4, diff --git a/docker-bake.hcl b/docker-bake.hcl index 7c603f0..aeab0de 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -19,6 +19,10 @@ variable "revision" { default = "1" } +variable "pgMajor" { + default = "18" +} + fullname = ( environment == "testing") ? "${registry}/postgresql-trunk-testing" : "${registry}/postgresql-trunk" now = timestamp() title = "PostgreSQL Trunk Containers" @@ -33,7 +37,7 @@ target "default" { "standard", "postgis" ] - pgMajor = ["18"] + pgMajor = ["${pgMajor}"] base = ["debian:bookworm-slim"] } @@ -42,7 +46,7 @@ target "default" { ] dockerfile = "Dockerfile" - name = "postgresql-${pgMajor}-${tgt}-${distroVersion(base)}" + name = "${tgt}" tags = [ "${fullname}:${pgMajor}-${tgt}-${distroVersion(base)}", "${fullname}:${pgMajor}-${formatdate("YYYYMMDDhhmm", now)}-${tgt}-${distroVersion(base)}" From 3ce5bc43d048de2449692d44d9be4240dd0f332f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Fei?= Date: Mon, 7 Apr 2025 17:21:11 +0200 Subject: [PATCH 3/6] ci: use bake in build.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niccolò Fei --- .github/workflows/build.yml | 66 +++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 758bfe2..b95bfd2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,13 +14,6 @@ on: major_version: description: "PostgreSQL major version (leave empty for default)" required: false - extra_tag: - description: "Optional extra tag (make sure it starts with the PG major)" - required: false - -# set up environment variables to be used across all the jobs -env: - REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk" defaults: run: @@ -35,7 +28,8 @@ jobs: contents: read packages: write outputs: - pg_image: ${{ env.TAG }} + images: ${{ env.IMAGES }} + pg_major: ${{ env.PG_MAJOR }} steps: - name: Checkout Code uses: actions/checkout@v4 @@ -53,16 +47,6 @@ jobs: echo "PG_MAJOR=${{ github.event.inputs.major_version }}" >> $GITHUB_ENV fi - - name: Set tag and optional extra tag - run: | - TAG="${{ env.REGISTRY }}:${{ env.PG_MAJOR }}-build-${{ github.run_number }}" - EXTRA_TAG="" - if [[ "${{ github.event.inputs.extra_tag }}" != "" ]]; then - EXTRA_TAG="${{ env.REGISTRY }}:${{ github.event.inputs.extra_tag }}" - fi - echo "TAG=${TAG}" >> $GITHUB_ENV - echo "EXTRA_TAG=${EXTRA_TAG}" >> $GITHUB_ENV - - name: Log in to the GitHub Container registry uses: docker/login-action@v3 with: @@ -70,18 +54,31 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push - uses: docker/build-push-action@v6 + uses: docker/bake-action@v6 + id: build + env: + environment: production + registry: ghcr.io/${{ github.repository_owner }} + revision: ${{ github.sha }} + pgMajor: ${{ env.PG_MAJOR }} with: - context: . + set: | + *.args.PG_REPO=${{ github.event.inputs.pg_repo }} + *.args.PG_BRANCH=${{ github.event.inputs.pg_branch }} + minimal.tags=${registry}/postgresql-trunk:18-minimal-${{ github.run_number }} + standard.tags=${registry}/postgresql-trunk:18-standard-${{ github.run_number }} + postgis.tags=${registry}/postgresql-trunk:18-postgis-${{ github.run_number }} push: true - load: false - tags: | - ${{ env.TAG }} - ${{ env.EXTRA_TAG }} - build-args: | - PG_REPO=${{ github.event.inputs.pg_repo }} - PG_BRANCH=${{ github.event.inputs.pg_branch }} + + # Get a list of the images that were built and pushed. + - name: Generated images + id: images + run: | + echo "IMAGES=$(echo '${{ steps.build.outputs.metadata }}' | jq -c '.[]."image.name"')" >> $GITHUB_ENV generate-summary: name: PostgreSQL Image Build summary @@ -92,11 +89,16 @@ jobs: - name: Output summary run: | pg_major="${{ needs.build-pg.outputs.pg_major }}" - image="${{ needs.build-pg.outputs.pg_image }}" - imageURL="https://${image}" + images="${{ needs.build-pg.outputs.images }}" + images_list="$(echo $images | jq -r | tr ' ' '\n' | sed 's/^/https:\/\//')" + standardImage="$(echo $images | jq -r | grep standard)" + standardImageURL="https://${standardImage}" + echo "# PostgreSQL Image Build summary" >> $GITHUB_STEP_SUMMARY - echo "**Container Image**: [$image]($imageURL)" >> $GITHUB_STEP_SUMMARY - echo "## CloudNativePG Cluster definition" >> $GITHUB_STEP_SUMMARY + echo "Here's the list of images that have been built:" >> $GITHUB_STEP_SUMMARY + echo "$images_list" >> $GITHUB_STEP_SUMMARY + + echo "## CloudNativePG Cluster definition (example using the standard image)" >> $GITHUB_STEP_SUMMARY echo "You can create a cluster in CloudNativePG running this image:" >> $GITHUB_STEP_SUMMARY echo "\`\`\`sh" >> $GITHUB_STEP_SUMMARY echo "(cat <> $GITHUB_STEP_SUMMARY @@ -105,7 +107,7 @@ jobs: echo "metadata:" >> $GITHUB_STEP_SUMMARY echo " name: pg-$pg_major-build" >> $GITHUB_STEP_SUMMARY echo "spec:" >> $GITHUB_STEP_SUMMARY - echo " imageName: $image" >> $GITHUB_STEP_SUMMARY + echo " imageName: $standardImage" >> $GITHUB_STEP_SUMMARY echo " instances: 3" >> $GITHUB_STEP_SUMMARY echo " storage:" >> $GITHUB_STEP_SUMMARY echo " size: 1Gi" >> $GITHUB_STEP_SUMMARY From 02b80c35fb28d205e0a9ee10d52a0411ac5c51b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Fei?= Date: Mon, 7 Apr 2025 17:44:04 +0200 Subject: [PATCH 4/6] ci: use bake in build-commitfest.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niccolò Fei --- .github/workflows/build-commitfest.yml | 54 ++++++++++++++++---------- .github/workflows/build.yml | 9 ++--- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-commitfest.yml b/.github/workflows/build-commitfest.yml index a00eefb..41d559f 100644 --- a/.github/workflows/build-commitfest.yml +++ b/.github/workflows/build-commitfest.yml @@ -5,16 +5,11 @@ on: inputs: patch_id: description: "ID of the Patch" - required: false + required: true major_version: description: "PostgreSQL major version (leave empty for default)" required: false -# set up environment variables to be used across all the jobs -env: - REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk" - BRANCH: "master" - defaults: run: # default failure handling for shell scripts in 'run' steps @@ -28,7 +23,7 @@ jobs: contents: read packages: write outputs: - pg_image: "${{ env.REGISTRY }}:${{ env.TAG }}" + images: ${{ env.IMAGES }} steps: - name: Checkout Code uses: actions/checkout@v4 @@ -47,10 +42,9 @@ jobs: fi - name: Set commitfest branch and tag - if: github.event.inputs.patch_id != '' run: | BRANCH="cf/${{ github.event.inputs.patch_id }}" - TAG="${{ env.PG_MAJOR }}-${BRANCH////-}" + TAG="${BRANCH////-}" echo "TAG=${TAG}" >> $GITHUB_ENV echo "BRANCH=${BRANCH}" >> $GITHUB_ENV @@ -61,17 +55,31 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push - uses: docker/build-push-action@v6 + uses: docker/bake-action@v6 + id: build + env: + environment: production + registry: ghcr.io/${{ github.repository_owner }} + revision: ${{ github.sha }} + pgMajor: ${{ env.PG_MAJOR }} with: - context: . + set: | + *.args.PG_REPO=https://github.com/postgresql-cfbot/postgresql.git + *.args.PG_BRANCH=${{ env.BRANCH }} + minimal.tags=${{ env.registry }}/postgresql-trunk:18-minimal-${{ env.TAG }} + standard.tags=${{ env.registry }}/postgresql-trunk:18-standard-${{ env.TAG }} + postgis.tags=${{ env.registry }}/postgresql-trunk:18-postgis-${{ env.TAG }} push: true - load: false - tags: | - ${{ env.REGISTRY }}:${{ env.TAG }} - build-args: | - PG_REPO=https://github.com/postgresql-cfbot/postgresql.git - PG_BRANCH=${{ env.BRANCH }} + + # Get a list of the images that were built and pushed. + - name: Generated images + id: images + run: | + echo "IMAGES=$(echo '${{ steps.build.outputs.metadata }}' | jq -c '.[]."image.name"')" >> $GITHUB_ENV generate-summary: name: Commitfest Image Build summary @@ -83,11 +91,15 @@ jobs: run: | commitFestPatchID=${{ github.event.inputs.patch_id }} commitFestURL="https://commitfest.postgresql.org/patch/${commitFestPatchID}" - image="${{ needs.build-pg.outputs.pg_image }}" - imageURL="https://${image}" + image="${{ needs.build-pg.outputs.images }}" + images_list="$(echo $images | jq -r | tr ' ' '\n' | sed 's/^/https:\/\//')" + standardImage="$(echo $images | jq -r | grep standard)" + echo "# Commitfest Image Build summary" >> $GITHUB_STEP_SUMMARY echo "**Commitfest Patch URL**: [$commitFestPatchID]($commitFestURL)" >> $GITHUB_STEP_SUMMARY - echo "**Container Image**: [$image]($imageURL)" >> $GITHUB_STEP_SUMMARY + echo "Here's the list of Container Images that have been built:" >> $GITHUB_STEP_SUMMARY + echo "$images_list" >> $GITHUB_STEP_SUMMARY + echo "## CloudNativePG Cluster definition" >> $GITHUB_STEP_SUMMARY echo "You can create a cluster in CloudNativePG running this image:" >> $GITHUB_STEP_SUMMARY echo "\`\`\`sh" >> $GITHUB_STEP_SUMMARY @@ -97,7 +109,7 @@ jobs: echo "metadata:" >> $GITHUB_STEP_SUMMARY echo " name: commitfest-$commitFestPatchID" >> $GITHUB_STEP_SUMMARY echo "spec:" >> $GITHUB_STEP_SUMMARY - echo " imageName: $image" >> $GITHUB_STEP_SUMMARY + echo " imageName: $standardImage" >> $GITHUB_STEP_SUMMARY echo " instances: 3" >> $GITHUB_STEP_SUMMARY echo " storage:" >> $GITHUB_STEP_SUMMARY echo " size: 1Gi" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b95bfd2..d7aa730 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,9 +69,9 @@ jobs: set: | *.args.PG_REPO=${{ github.event.inputs.pg_repo }} *.args.PG_BRANCH=${{ github.event.inputs.pg_branch }} - minimal.tags=${registry}/postgresql-trunk:18-minimal-${{ github.run_number }} - standard.tags=${registry}/postgresql-trunk:18-standard-${{ github.run_number }} - postgis.tags=${registry}/postgresql-trunk:18-postgis-${{ github.run_number }} + minimal.tags=${{ env.registry }}/postgresql-trunk:18-minimal-${{ github.run_number }} + standard.tags=${{ env.registry }}/postgresql-trunk:18-standard-${{ github.run_number }} + postgis.tags=${{ env.registry }}/postgresql-trunk:18-postgis-${{ github.run_number }} push: true # Get a list of the images that were built and pushed. @@ -92,10 +92,9 @@ jobs: images="${{ needs.build-pg.outputs.images }}" images_list="$(echo $images | jq -r | tr ' ' '\n' | sed 's/^/https:\/\//')" standardImage="$(echo $images | jq -r | grep standard)" - standardImageURL="https://${standardImage}" echo "# PostgreSQL Image Build summary" >> $GITHUB_STEP_SUMMARY - echo "Here's the list of images that have been built:" >> $GITHUB_STEP_SUMMARY + echo "Here's the list of Container Images that have been built:" >> $GITHUB_STEP_SUMMARY echo "$images_list" >> $GITHUB_STEP_SUMMARY echo "## CloudNativePG Cluster definition (example using the standard image)" >> $GITHUB_STEP_SUMMARY From 9f1af554e97ea2cca63cd9064b8982052ce39b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Fei?= Date: Mon, 7 Apr 2025 17:58:32 +0200 Subject: [PATCH 5/6] fix: adjust DefaultImageName MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niccolò Fei --- .github/workflows/build-commitfest.yml | 13 +++++++++---- .github/workflows/build.yml | 11 ++++++++--- .github/workflows/continuous-delivery.yml | 2 +- .github/workflows/reusable-e2e.yml | 5 +++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-commitfest.yml b/.github/workflows/build-commitfest.yml index 41d559f..3441b51 100644 --- a/.github/workflows/build-commitfest.yml +++ b/.github/workflows/build-commitfest.yml @@ -79,7 +79,12 @@ jobs: - name: Generated images id: images run: | - echo "IMAGES=$(echo '${{ steps.build.outputs.metadata }}' | jq -c '.[]."image.name"')" >> $GITHUB_ENV + IMAGES="$(echo '${{ steps.build.outputs.metadata }}' | jq -r '.[]."image.name"')" + { + echo 'IMAGES<> $GITHUB_ENV generate-summary: name: Commitfest Image Build summary @@ -91,9 +96,9 @@ jobs: run: | commitFestPatchID=${{ github.event.inputs.patch_id }} commitFestURL="https://commitfest.postgresql.org/patch/${commitFestPatchID}" - image="${{ needs.build-pg.outputs.images }}" - images_list="$(echo $images | jq -r | tr ' ' '\n' | sed 's/^/https:\/\//')" - standardImage="$(echo $images | jq -r | grep standard)" + images="${{ needs.build-pg.outputs.images }}" + images_list="$(echo $images | tr ' ' '\n' | sed 's/^/https:\/\//')" + standardImage="$(echo $images | tr ' ' '\n' | grep standard)" echo "# Commitfest Image Build summary" >> $GITHUB_STEP_SUMMARY echo "**Commitfest Patch URL**: [$commitFestPatchID]($commitFestURL)" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d7aa730..b7f70fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,12 @@ jobs: - name: Generated images id: images run: | - echo "IMAGES=$(echo '${{ steps.build.outputs.metadata }}' | jq -c '.[]."image.name"')" >> $GITHUB_ENV + IMAGES="$(echo '${{ steps.build.outputs.metadata }}' | jq -r '.[]."image.name"')" + { + echo 'IMAGES<> $GITHUB_ENV generate-summary: name: PostgreSQL Image Build summary @@ -90,8 +95,8 @@ jobs: run: | pg_major="${{ needs.build-pg.outputs.pg_major }}" images="${{ needs.build-pg.outputs.images }}" - images_list="$(echo $images | jq -r | tr ' ' '\n' | sed 's/^/https:\/\//')" - standardImage="$(echo $images | jq -r | grep standard)" + images_list="$(echo $images | tr ' ' '\n' | sed 's/^/https:\/\//')" + standardImage="$(echo $images | tr ' ' '\n' | grep standard)" echo "# PostgreSQL Image Build summary" >> $GITHUB_STEP_SUMMARY echo "Here's the list of Container Images that have been built:" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 20b09c1..9b6df45 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -80,7 +80,7 @@ jobs: - name: Generated images id: images run: | - echo "PG_IMAGE=$(echo '${{ steps.build.outputs.metadata }}' | jq -c '.["standard"].["image.name"]' | grep -oP '[^,]*\d{12}[^,]*')" >> $GITHUB_ENV + echo "PG_IMAGE=$(echo '${{ steps.build.outputs.metadata }}' | jq -r '.["standard"].["image.name"]' | grep -oP '[^,]*\d{12}[^,]*')" >> $GITHUB_ENV call-reusable-e2e: if: github.event_name == 'schedule' diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 7d5e09f..83169c6 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -127,6 +127,11 @@ jobs: docker push $E2E_PRE_ROLLING_UPDATE_IMG echo "E2E_PRE_ROLLING_UPDATE_IMG=$E2E_PRE_ROLLING_UPDATE_IMG" >> $GITHUB_ENV + - name: Setting up default versions + run: | + # Update pkg/versions/versions.go + sed -i '/DefaultImageName *=/s@".*"@"'"${{ inputs.postgres_img }}"'"@' pkg/versions/versions.go + - name: Run Kind End-to-End tests run: make e2e-test-kind From be02ae3c5564ce2dbdd34c2e905abf462166088e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Fei?= Date: Tue, 8 Apr 2025 13:57:50 +0200 Subject: [PATCH 6/6] ci: env variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niccolò Fei --- .github/workflows/reusable-e2e.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 83169c6..40fe3e2 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -48,6 +48,7 @@ jobs: POSTGRES_VERSION: ${{ inputs.major_version }} POSTGRES_IMG: ${{ inputs.postgres_img }} POSTGRES_KIND: "PostgreSQL" + MAJOR_UPGRADE_IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk" DOCKER_SERVER: ghcr.io DOCKER_USERNAME: ${{ github.actor }}