From 79cef7f6a9261f35a164b26770ffa6a9af1e6056 Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 12:01:49 +0000 Subject: [PATCH 01/10] Bumping version to 1.3.0 --- VERSION | 2 +- VERSION_MINOR | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index cb174d5..589268e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.1 \ No newline at end of file +1.3.0 \ No newline at end of file diff --git a/VERSION_MINOR b/VERSION_MINOR index ea710ab..a58941b 100644 --- a/VERSION_MINOR +++ b/VERSION_MINOR @@ -1 +1 @@ -1.2 \ No newline at end of file +1.3 \ No newline at end of file From cf2ecd018d68e1e5be243819a6bf3581051e501c Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 12:01:57 +0000 Subject: [PATCH 02/10] Using latest base images --- 12/Dockerfile | 5 ++++- 13/Dockerfile | 5 ++++- 14/Dockerfile | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/12/Dockerfile b/12/Dockerfile index 6da420c..58286d8 100644 --- a/12/Dockerfile +++ b/12/Dockerfile @@ -1,4 +1,7 @@ -FROM bfren/alpine-s6:alpine3.15-3.0.2 +FROM bfren/alpine-s6:alpine3.15-3.1.1 + +ARG BF_IMAGE +ARG BF_VERSION ENV \ # set to "1" to compress backup sql files diff --git a/13/Dockerfile b/13/Dockerfile index df840be..95f824f 100644 --- a/13/Dockerfile +++ b/13/Dockerfile @@ -1,4 +1,7 @@ -FROM bfren/alpine-s6:alpine3.15-3.0.2 +FROM bfren/alpine-s6:alpine3.15-3.1.1 + +ARG BF_IMAGE +ARG BF_VERSION ENV \ # set to "1" to compress backup sql files diff --git a/14/Dockerfile b/14/Dockerfile index a078f08..e48d695 100644 --- a/14/Dockerfile +++ b/14/Dockerfile @@ -1,4 +1,7 @@ -FROM bfren/alpine-s6:alpine3.15-3.0.2 +FROM bfren/alpine-s6:alpine3.15-3.1.1 + +ARG BF_IMAGE +ARG BF_VERSION ENV \ # set to "1" to compress backup sql files From e49c80ebde6923e83fdfb36d77b4902c32a13fdc Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 12:02:05 +0000 Subject: [PATCH 03/10] Adding image name / version to builds --- .github/workflows/dev-12.yml | 7 +++++++ .github/workflows/dev-13.yml | 7 +++++++ .github/workflows/dev-14.yml | 7 +++++++ .github/workflows/publish-12.yml | 7 +++++++ .github/workflows/publish-13.yml | 7 +++++++ .github/workflows/publish-14.yml | 7 +++++++ 6 files changed, 42 insertions(+) diff --git a/.github/workflows/dev-12.yml b/.github/workflows/dev-12.yml index 5e726b3..0e0043a 100644 --- a/.github/workflows/dev-12.yml +++ b/.github/workflows/dev-12.yml @@ -21,6 +21,10 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - + name: Get repository name + run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV + shell: bash - name: Read image version uses: bfren/read-file@v1 @@ -46,6 +50,9 @@ jobs: with: context: . file: ./12/Dockerfile + build-args: | + BF_IMAGE=${{ env.REPOSITORY_NAME }} + BF_VERSION=${{ steps.version.outputs.contents }} push: ${{ startsWith(github.ref, 'refs/heads/') }} platforms: linux/amd64,linux/arm/v7,linux/arm64 tags: | diff --git a/.github/workflows/dev-13.yml b/.github/workflows/dev-13.yml index aa2dba2..d205f18 100644 --- a/.github/workflows/dev-13.yml +++ b/.github/workflows/dev-13.yml @@ -21,6 +21,10 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - + name: Get repository name + run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV + shell: bash - name: Read image version uses: bfren/read-file@v1 @@ -46,6 +50,9 @@ jobs: with: context: . file: ./13/Dockerfile + build-args: | + BF_IMAGE=${{ env.REPOSITORY_NAME }} + BF_VERSION=${{ steps.version.outputs.contents }} push: ${{ startsWith(github.ref, 'refs/heads/') }} platforms: linux/amd64,linux/arm/v7,linux/arm64 tags: | diff --git a/.github/workflows/dev-14.yml b/.github/workflows/dev-14.yml index 715010c..cb1590d 100644 --- a/.github/workflows/dev-14.yml +++ b/.github/workflows/dev-14.yml @@ -21,6 +21,10 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - + name: Get repository name + run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV + shell: bash - name: Read image version uses: bfren/read-file@v1 @@ -46,6 +50,9 @@ jobs: with: context: . file: ./14/Dockerfile + build-args: | + BF_IMAGE=${{ env.REPOSITORY_NAME }} + BF_VERSION=${{ steps.version.outputs.contents }} push: ${{ startsWith(github.ref, 'refs/heads/') }} platforms: linux/amd64,linux/arm/v7,linux/arm64 tags: | diff --git a/.github/workflows/publish-12.yml b/.github/workflows/publish-12.yml index 35d61e1..763f615 100644 --- a/.github/workflows/publish-12.yml +++ b/.github/workflows/publish-12.yml @@ -12,6 +12,10 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - + name: Get repository name + run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV + shell: bash - name: Read PostgreSQL version - minor uses: bfren/read-file@v1 @@ -61,6 +65,9 @@ jobs: with: context: . file: ./12/Dockerfile + build-args: | + BF_IMAGE=${{ env.REPOSITORY_NAME }} + BF_VERSION=${{ steps.version.outputs.contents }} push: true platforms: linux/amd64,linux/arm/v7,linux/arm64 tags: | diff --git a/.github/workflows/publish-13.yml b/.github/workflows/publish-13.yml index 5e0310c..247ff31 100644 --- a/.github/workflows/publish-13.yml +++ b/.github/workflows/publish-13.yml @@ -12,6 +12,10 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - + name: Get repository name + run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV + shell: bash - name: Read PostgreSQL version - minor uses: bfren/read-file@v1 @@ -61,6 +65,9 @@ jobs: with: context: . file: ./13/Dockerfile + build-args: | + BF_IMAGE=${{ env.REPOSITORY_NAME }} + BF_VERSION=${{ steps.version.outputs.contents }} push: true platforms: linux/amd64,linux/arm/v7,linux/arm64 tags: | diff --git a/.github/workflows/publish-14.yml b/.github/workflows/publish-14.yml index b6c9330..7eb76df 100644 --- a/.github/workflows/publish-14.yml +++ b/.github/workflows/publish-14.yml @@ -12,6 +12,10 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - + name: Get repository name + run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV + shell: bash - name: Read PostgreSQL version - minor uses: bfren/read-file@v1 @@ -61,6 +65,9 @@ jobs: with: context: . file: ./14/Dockerfile + build-args: | + BF_IMAGE=${{ env.REPOSITORY_NAME }} + BF_VERSION=${{ steps.version.outputs.contents }} push: true platforms: linux/amd64,linux/arm/v7,linux/arm64 tags: | From 7550529a57ebf3bdf2c6e57d7546b704d822ee21 Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 15:52:20 +0000 Subject: [PATCH 04/10] Add version check --- overlay/etc/cont-init.d/10-env | 3 +++ overlay/etc/cont-init.d/12-postgresql-init | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/overlay/etc/cont-init.d/10-env b/overlay/etc/cont-init.d/10-env index 53fc822..8d80c45 100644 --- a/overlay/etc/cont-init.d/10-env +++ b/overlay/etc/cont-init.d/10-env @@ -17,3 +17,6 @@ bf-env "POSTGRESQL_BACKUP" "${POSTGRESQL_BACKUP}" bf-env "POSTGRESQL_BACKUP_FILENAME" "dump" bf-env "POSTGRESQL_RESTORE" "${POSTGRESQL_BACKUP}/restore.sql" + +bf-env "POSTGRESQL_SERVER_VERSION" `cat /usr/libexec/postgresql/PG_VERSION` +[[ -f "/data/PG_VERSION" ]] && bf-env "POSTGRESQL_DATA_VERSION" `cat /data/PG_VERSION` diff --git a/overlay/etc/cont-init.d/12-postgresql-init b/overlay/etc/cont-init.d/12-postgresql-init index 873a5ec..928a74a 100644 --- a/overlay/etc/cont-init.d/12-postgresql-init +++ b/overlay/etc/cont-init.d/12-postgresql-init @@ -35,6 +35,19 @@ stop () { } +#====================================================================================================================== +# Check data version against server version. +#====================================================================================================================== + +if [[ -z "${POSTGRESQL_DATA_VERSION-}" ]] || [[ "${POSTGRESQL_DATA_VERSION}" = "${POSTGRESQL_SERVER_VERSION}" ]] ; then + bf-debug "Versions ok." +else + MSG="PostgreSQL server (v${POSTGRESQL_SERVER_VERSION}) does not match data (v${POSTGRESQL_DATA_VERSION}). " + MSG+="You must us db-upgrade or choose an image that matches the data version." + bf-error ${MSG} +fi + + #====================================================================================================================== # Check for restore file. #====================================================================================================================== From 7682aa6357b92ca20a3ff85ed2f3642fb908e845 Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 16:41:50 +0000 Subject: [PATCH 05/10] Improving formatting of README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a72db70..49d09bd 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,11 @@ See [For Backups](#for-backups) for configuration variables. ### For Database -| Variable | Values | Description | Default | -| ----------------------- | ------ | ----------------------------------------------------------------------------------------------------- | ----------------- | -| `POSTGRESQL_USERNAME` | string | Application username - will be used as database name if `POSTGRESQL_DATABASE` is not set. | *None* - required | -| `POSTGRESQL_PASSWORD` | string | Application password. | *None* - required | -| `POSTGRESQL_DATABASE` | string | Database name(s) - multiple databases can be separated by a comma. | *None* | +| Variable | Values | Description | Default | +| --------------------- | ------ | ----------------------------------------------------------------------------------------- | ----------------- | +| `POSTGRESQL_USERNAME` | string | Application username - will be used as database name if `POSTGRESQL_DATABASE` is not set. | *None* - required | +| `POSTGRESQL_PASSWORD` | string | Application password. | *None* - required | +| `POSTGRESQL_DATABASE` | string | Database name(s) - multiple databases can be separated by a comma. | *None* | ## Helper Functions From 005a19bf6899439449a4a4433c37b1c72fa60040 Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 17:29:18 +0000 Subject: [PATCH 06/10] Actually load versions before checking them... --- overlay/etc/cont-init.d/12-postgresql-init | 3 +++ 1 file changed, 3 insertions(+) diff --git a/overlay/etc/cont-init.d/12-postgresql-init b/overlay/etc/cont-init.d/12-postgresql-init index 928a74a..f882488 100644 --- a/overlay/etc/cont-init.d/12-postgresql-init +++ b/overlay/etc/cont-init.d/12-postgresql-init @@ -39,6 +39,9 @@ stop () { # Check data version against server version. #====================================================================================================================== +[[ -f "/data/PG_VERSION" ]] && POSTGRESQL_DATA_VERSION=`cat /data/PG_VERSION` +POSTGRESQL_SERVER_VERSION=`cat /usr/libexec/postgresql/PG_VERSION` + if [[ -z "${POSTGRESQL_DATA_VERSION-}" ]] || [[ "${POSTGRESQL_DATA_VERSION}" = "${POSTGRESQL_SERVER_VERSION}" ]] ; then bf-debug "Versions ok." else From cafaea01623fdf52d629c75b219519c60987a19b Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 17:30:34 +0000 Subject: [PATCH 07/10] Terminate container when versions don't match --- overlay/etc/cont-init.d/12-postgresql-init | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/overlay/etc/cont-init.d/12-postgresql-init b/overlay/etc/cont-init.d/12-postgresql-init index f882488..9da7e5c 100644 --- a/overlay/etc/cont-init.d/12-postgresql-init +++ b/overlay/etc/cont-init.d/12-postgresql-init @@ -47,7 +47,9 @@ if [[ -z "${POSTGRESQL_DATA_VERSION-}" ]] || [[ "${POSTGRESQL_DATA_VERSION}" = " else MSG="PostgreSQL server (v${POSTGRESQL_SERVER_VERSION}) does not match data (v${POSTGRESQL_DATA_VERSION}). " MSG+="You must us db-upgrade or choose an image that matches the data version." - bf-error ${MSG} + bf-notok ${MSG} + s6-svscanctl -t ${S6_SERVICES} + exit 1 fi From 0f97760fdeeae1bcd7ac46120c7d365863d87467 Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 17:35:58 +0000 Subject: [PATCH 08/10] Fixing concatenation --- overlay/etc/cont-init.d/12-postgresql-init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/overlay/etc/cont-init.d/12-postgresql-init b/overlay/etc/cont-init.d/12-postgresql-init index 9da7e5c..de37140 100644 --- a/overlay/etc/cont-init.d/12-postgresql-init +++ b/overlay/etc/cont-init.d/12-postgresql-init @@ -45,8 +45,8 @@ POSTGRESQL_SERVER_VERSION=`cat /usr/libexec/postgresql/PG_VERSION` if [[ -z "${POSTGRESQL_DATA_VERSION-}" ]] || [[ "${POSTGRESQL_DATA_VERSION}" = "${POSTGRESQL_SERVER_VERSION}" ]] ; then bf-debug "Versions ok." else - MSG="PostgreSQL server (v${POSTGRESQL_SERVER_VERSION}) does not match data (v${POSTGRESQL_DATA_VERSION}). " - MSG+="You must us db-upgrade or choose an image that matches the data version." + MSG="PostgreSQL server (v${POSTGRESQL_SERVER_VERSION}) does not match data (v${POSTGRESQL_DATA_VERSION})." + MSG="${MSG}\nYou must upgrade the data or use a version of this image that matches the data version." bf-notok ${MSG} s6-svscanctl -t ${S6_SERVICES} exit 1 From ec566bdca69e8d74b569026dedd7db02ed403983 Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 17:39:02 +0000 Subject: [PATCH 09/10] Quoting message --- overlay/etc/cont-init.d/12-postgresql-init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overlay/etc/cont-init.d/12-postgresql-init b/overlay/etc/cont-init.d/12-postgresql-init index de37140..313d006 100644 --- a/overlay/etc/cont-init.d/12-postgresql-init +++ b/overlay/etc/cont-init.d/12-postgresql-init @@ -47,7 +47,7 @@ if [[ -z "${POSTGRESQL_DATA_VERSION-}" ]] || [[ "${POSTGRESQL_DATA_VERSION}" = " else MSG="PostgreSQL server (v${POSTGRESQL_SERVER_VERSION}) does not match data (v${POSTGRESQL_DATA_VERSION})." MSG="${MSG}\nYou must upgrade the data or use a version of this image that matches the data version." - bf-notok ${MSG} + bf-notok "${MSG}" s6-svscanctl -t ${S6_SERVICES} exit 1 fi From 9fc263d521c399b7bc6f9e818bba06173431516f Mon Sep 17 00:00:00 2001 From: Ben Green Date: Fri, 3 Dec 2021 17:41:35 +0000 Subject: [PATCH 10/10] Improving output when versions don't match --- overlay/etc/cont-init.d/12-postgresql-init | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/overlay/etc/cont-init.d/12-postgresql-init b/overlay/etc/cont-init.d/12-postgresql-init index 313d006..a7ad1eb 100644 --- a/overlay/etc/cont-init.d/12-postgresql-init +++ b/overlay/etc/cont-init.d/12-postgresql-init @@ -45,9 +45,9 @@ POSTGRESQL_SERVER_VERSION=`cat /usr/libexec/postgresql/PG_VERSION` if [[ -z "${POSTGRESQL_DATA_VERSION-}" ]] || [[ "${POSTGRESQL_DATA_VERSION}" = "${POSTGRESQL_SERVER_VERSION}" ]] ; then bf-debug "Versions ok." else - MSG="PostgreSQL server (v${POSTGRESQL_SERVER_VERSION}) does not match data (v${POSTGRESQL_DATA_VERSION})." - MSG="${MSG}\nYou must upgrade the data or use a version of this image that matches the data version." - bf-notok "${MSG}" + bf-notok "PostgreSQL server (v${POSTGRESQL_SERVER_VERSION}) does not match data (v${POSTGRESQL_DATA_VERSION})." + bf-notok "You must upgrade the data or use a version of this image that matches the data version." + bf-notok "Container will now quit." s6-svscanctl -t ${S6_SERVICES} exit 1 fi