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: | 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 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 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 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..a7ad1eb 100644 --- a/overlay/etc/cont-init.d/12-postgresql-init +++ b/overlay/etc/cont-init.d/12-postgresql-init @@ -35,6 +35,24 @@ 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 + 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 + + #====================================================================================================================== # Check for restore file. #======================================================================================================================