From 1fa074892ee32798399ee71c8ae542f35c911eb4 Mon Sep 17 00:00:00 2001 From: Dennis Schwarzer Date: Wed, 21 Jan 2026 16:38:31 +0100 Subject: [PATCH 1/8] - [#66] Update postgresql to 14.20 by using dockerhub image instead of alpine upstream - [#66] Update base image to 3.23.2-2 --- CHANGELOG.md | 3 +++ Dockerfile | 40 +++++++++++++--------------------------- dogu.json | 2 +- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b056fb6..413754e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- [#66] Update postgresql to 14.20 by using dockerhub image instead of alpine upstream +- [#66] Update base image to 3.23.2-2 ## [v14.18-3] - 2025-09-19 ### Added diff --git a/Dockerfile b/Dockerfile index 11e60fe..ba92af1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,39 +1,25 @@ -FROM registry.cloudogu.com/official/base:3.18.9-3 AS builder +FROM registry.cloudogu.com/official/base:3.23.2-2 AS builder -ENV GOSU_SHA256=bbc4136d03ab138b1ad66fa4fc051bafc6cc7ffae632b069a53657279a450de3 +# doguctl -WORKDIR /build - -RUN set -x -o errexit \ - && set -o nounset \ - && set -o pipefail \ - && apk update \ - && apk upgrade \ - && apk add wget \ - && mkdir -p /build/usr/local/bin \ - && wget --progress=bar:force:noscroll -O /build/usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.17/gosu-amd64" \ - && echo "${GOSU_SHA256} */build/usr/local/bin/gosu" | sha256sum -c - \ - && chmod +x /build/usr/local/bin/gosu - -FROM registry.cloudogu.com/official/base:3.18.9-3 +FROM postgres:14.20-alpine3.23 LABEL NAME="official/postgresql" \ - VERSION="14.18-3" \ - maintainer="hello@cloudogu.com" + VERSION="14.20-0" \ + maintainer="hello@cloudogu.com" +# === ENV: keep exactly the same contracts === ENV LANG=en_US.utf8 \ - PGDATA=/var/lib/postgresql \ - POSTGRESQL_VERSION=14.18-r0 + PGDATA=/var/lib/postgresql -RUN set -x -o errexit \ - && set -o nounset \ - && set -o pipefail \ - && apk update \ - && apk upgrade \ - && apk add --no-cache --update postgresql14="${POSTGRESQL_VERSION}" postgresql14-contrib="${POSTGRESQL_VERSION}" +# === Copy doguctl (same as before) === +COPY --from=builder /usr/local/bin/doguctl /usr/local/bin/ COPY resources/ / -COPY --from=builder /build / + +RUN set -eux; \ + mkdir -p "$PGDATA"; \ + chown -R postgres:postgres /var/lib/postgresql VOLUME ["/var/lib/postgresql"] diff --git a/dogu.json b/dogu.json index eb9206a..f540d72 100644 --- a/dogu.json +++ b/dogu.json @@ -1,6 +1,6 @@ { "Name": "official/postgresql", - "Version": "14.18-3", + "Version": "14.20-0", "DisplayName": "PostgreSQL", "Description": "PostgreSQL Database.", "Url": "https://www.postgresql.org/", From b7b10eedd301657874e84804013be67ea6c3b7a6 Mon Sep 17 00:00:00 2001 From: Dennis Schwarzer Date: Wed, 21 Jan 2026 16:54:03 +0100 Subject: [PATCH 2/8] #66 health check fix --- Dockerfile | 5 ++--- resources/startup.sh | 14 +++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index ba92af1..8103abd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM registry.cloudogu.com/official/base:3.23.2-2 AS builder -# doguctl +# get doguctl FROM postgres:14.20-alpine3.23 @@ -8,11 +8,10 @@ LABEL NAME="official/postgresql" \ VERSION="14.20-0" \ maintainer="hello@cloudogu.com" -# === ENV: keep exactly the same contracts === ENV LANG=en_US.utf8 \ PGDATA=/var/lib/postgresql -# === Copy doguctl (same as before) === +# === Copy doguctl === COPY --from=builder /usr/local/bin/doguctl /usr/local/bin/ COPY resources/ / diff --git a/resources/startup.sh b/resources/startup.sh index 9c9106b..bc9827e 100755 --- a/resources/startup.sh +++ b/resources/startup.sh @@ -155,11 +155,19 @@ function runMain() { setDoguLogLevel setMaxConnections - # set stage for health check + # start database in background + gosu postgres postgres & + + POSTGRES_PID=$! + + # wait until it is actually accepting connections + waitForPostgreSQLStartup + + # NOW mark ready doguctl state ready - # start database - exec gosu postgres postgres + # re-exec postgres as PID 1 (signal-safe) + wait "$POSTGRES_PID" } # make the script only run when executed, not when sourced from bats tests From fb937b1fb535feba2af0b7e5ea8abb2aab174aeb Mon Sep 17 00:00:00 2001 From: Dennis Schwarzer Date: Wed, 21 Jan 2026 17:03:34 +0100 Subject: [PATCH 3/8] #66 fix goss --- resources/startup.sh | 14 +++----------- spec/goss/goss.yaml | 3 --- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/resources/startup.sh b/resources/startup.sh index bc9827e..9c9106b 100755 --- a/resources/startup.sh +++ b/resources/startup.sh @@ -155,19 +155,11 @@ function runMain() { setDoguLogLevel setMaxConnections - # start database in background - gosu postgres postgres & - - POSTGRES_PID=$! - - # wait until it is actually accepting connections - waitForPostgreSQLStartup - - # NOW mark ready + # set stage for health check doguctl state ready - # re-exec postgres as PID 1 (signal-safe) - wait "$POSTGRES_PID" + # start database + exec gosu postgres postgres } # make the script only run when executed, not when sourced from bats tests diff --git a/spec/goss/goss.yaml b/spec/goss/goss.yaml index 25f96d9..bed15a0 100644 --- a/spec/goss/goss.yaml +++ b/spec/goss/goss.yaml @@ -38,9 +38,6 @@ file: exists: true owner: postgres filetype: directory -package: - postgresql14: - installed: true port: tcp:5432: listening: true From 40f9dcd801f902185ab1f1c01a312ed97cf7d24b Mon Sep 17 00:00:00 2001 From: Dennis Schwarzer Date: Wed, 21 Jan 2026 17:43:42 +0100 Subject: [PATCH 4/8] #66 adjust startup --- Dockerfile | 2 +- resources/startup.sh | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8103abd..1a67bf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ LABEL NAME="official/postgresql" \ maintainer="hello@cloudogu.com" ENV LANG=en_US.utf8 \ - PGDATA=/var/lib/postgresql + PGDATA=/var/lib/postgresql/data # === Copy doguctl === COPY --from=builder /usr/local/bin/doguctl /usr/local/bin/ diff --git a/resources/startup.sh b/resources/startup.sh index 9c9106b..1c800fe 100755 --- a/resources/startup.sh +++ b/resources/startup.sh @@ -126,15 +126,15 @@ function setDoguLogLevel() { ;; esac # Remove old log level setting, if existent - sed -i '/^log_min_messages/d' /var/lib/postgresql/postgresql.conf + sed -i '/^log_min_messages/d' ${PGDATA}/postgresql.conf # Append new log level setting - echo "log_min_messages = ${POSTGRESQL_LOGLEVEL}" >>/var/lib/postgresql/postgresql.conf + echo "log_min_messages = ${POSTGRESQL_LOGLEVEL}" >> ${PGDATA}/postgresql.conf } function setMaxConnections() { # replace default max connection count with configured max connection count cons=$(doguctl config 'database_config/max_connections') - sed -i "/max_connections/c\max_connections = ${cons}" /var/lib/postgresql/postgresql.conf + sed -i "/max_connections/c\max_connections = ${cons}" ${PGDATA}/postgresql.conf } function runMain() { @@ -147,7 +147,7 @@ function runMain() { # Give the postgres user the necessary permissions chownPgdata - if [ -z "$(ls -A "$PGDATA")" ]; then + if [ ! -f "$PGDATA/PG_VERSION" ]; then initializePostgreSQL fi @@ -155,11 +155,18 @@ function runMain() { setDoguLogLevel setMaxConnections - # set stage for health check + # start postgres in background + gosu postgres postgres & + POSTGRES_PID=$! + + # wait until it actually accepts connections + waitForPostgreSQLStartup + + # NOW mark ready doguctl state ready - # start database - exec gosu postgres postgres + # hand over PID 1 lifecycle to postgres + wait "$POSTGRES_PID" } # make the script only run when executed, not when sourced from bats tests From 1f231cb03c13ff0f1961a637665e18fe06a0e010 Mon Sep 17 00:00:00 2001 From: Dennis Schwarzer Date: Wed, 21 Jan 2026 17:46:23 +0100 Subject: [PATCH 5/8] #66 shellcheck --- resources/startup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/startup.sh b/resources/startup.sh index 1c800fe..57fdb1f 100755 --- a/resources/startup.sh +++ b/resources/startup.sh @@ -126,15 +126,15 @@ function setDoguLogLevel() { ;; esac # Remove old log level setting, if existent - sed -i '/^log_min_messages/d' ${PGDATA}/postgresql.conf + sed -i '/^log_min_messages/d' "${PGDATA}"/postgresql.conf # Append new log level setting - echo "log_min_messages = ${POSTGRESQL_LOGLEVEL}" >> ${PGDATA}/postgresql.conf + echo "log_min_messages = ${POSTGRESQL_LOGLEVEL}" >> "${PGDATA}"/postgresql.conf } function setMaxConnections() { # replace default max connection count with configured max connection count cons=$(doguctl config 'database_config/max_connections') - sed -i "/max_connections/c\max_connections = ${cons}" ${PGDATA}/postgresql.conf + sed -i "/max_connections/c\max_connections = ${cons}" "${PGDATA}"/postgresql.conf } function runMain() { From e2a960aa2142bda74cab0b25a511a87d1eb89a5e Mon Sep 17 00:00:00 2001 From: Dennis Schwarzer Date: Wed, 21 Jan 2026 18:18:43 +0100 Subject: [PATCH 6/8] #66 shellcheck --- Dockerfile | 2 ++ spec/goss/goss.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1a67bf3..cc36156 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,8 @@ RUN set -eux; \ mkdir -p "$PGDATA"; \ chown -R postgres:postgres /var/lib/postgresql +RUN apk add --no-cache libc6-compat shadow + VOLUME ["/var/lib/postgresql"] HEALTHCHECK --interval=5s CMD doguctl healthy postgresql || exit 1 diff --git a/spec/goss/goss.yaml b/spec/goss/goss.yaml index bed15a0..2baa086 100644 --- a/spec/goss/goss.yaml +++ b/spec/goss/goss.yaml @@ -34,7 +34,7 @@ file: owner: root group: root filetype: file - /var/lib/postgresql: + /var/lib/postgresql/data: exists: true owner: postgres filetype: directory From e3485c306bfc4c54ecb9b5afa183545f07b9ead0 Mon Sep 17 00:00:00 2001 From: Dennis Schwarzer Date: Wed, 21 Jan 2026 18:26:44 +0100 Subject: [PATCH 7/8] #66 revert startup --- resources/startup.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/resources/startup.sh b/resources/startup.sh index 57fdb1f..e8d27bc 100755 --- a/resources/startup.sh +++ b/resources/startup.sh @@ -155,18 +155,11 @@ function runMain() { setDoguLogLevel setMaxConnections - # start postgres in background - gosu postgres postgres & - POSTGRES_PID=$! - - # wait until it actually accepts connections - waitForPostgreSQLStartup - - # NOW mark ready + # set stage for health check doguctl state ready - # hand over PID 1 lifecycle to postgres - wait "$POSTGRES_PID" + # start database + exec gosu postgres postgres } # make the script only run when executed, not when sourced from bats tests From 9020685f55f3c76e529dfb312c3a3f874b536fd8 Mon Sep 17 00:00:00 2001 From: Dennis Schwarzer Date: Thu, 22 Jan 2026 12:47:45 +0100 Subject: [PATCH 8/8] #66 fix upgrade script + migration --- Dockerfile | 10 +++++----- resources/post-upgrade.sh | 21 ++++++++++++++++++++- resources/util.sh | 2 ++ spec/goss/goss.yaml | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index cc36156..4fefdc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,15 +17,15 @@ COPY --from=builder /usr/local/bin/doguctl /usr/local/bin/ COPY resources/ / RUN set -eux; \ - mkdir -p "$PGDATA"; \ - chown -R postgres:postgres /var/lib/postgresql + mkdir -p "${PGDATA}"; \ + chown -R postgres:postgres "${PGDATA}" -RUN apk add --no-cache libc6-compat shadow - -VOLUME ["/var/lib/postgresql"] +VOLUME ["/var/lib/postgresql/data"] HEALTHCHECK --interval=5s CMD doguctl healthy postgresql || exit 1 EXPOSE 5432 +ENTRYPOINT [] + CMD ["/startup.sh"] diff --git a/resources/post-upgrade.sh b/resources/post-upgrade.sh index 643c53a..1db89f5 100755 --- a/resources/post-upgrade.sh +++ b/resources/post-upgrade.sh @@ -21,7 +21,26 @@ function prepareForBackup() { function startPostgresql() { echo "start postgresql" - gosu postgres postgres & + + # Migrate legacy PGDATA layout: + # Older images (/dev/null; do diff --git a/resources/util.sh b/resources/util.sh index 8071f2b..8a481f0 100644 --- a/resources/util.sh +++ b/resources/util.sh @@ -8,6 +8,8 @@ function initializePostgreSQL() { # set stage for health check doguctl state installing + ls -la $PGDATA + # install database gosu postgres initdb diff --git a/spec/goss/goss.yaml b/spec/goss/goss.yaml index 2baa086..c9a3052 100644 --- a/spec/goss/goss.yaml +++ b/spec/goss/goss.yaml @@ -47,6 +47,6 @@ process: postgres: running: true mount: - /var/lib/postgresql: + /var/lib/postgresql/data: exists: true filesystem: btrfs