postgresql 15 upgrade (#392)

* postgresql 15 upgrade

* fix compose

* fix workflows
pull/396/head
mazano 2022-10-26 07:39:14 +02:00 zatwierdzone przez GitHub
rodzic ec57044706
commit 6fc6147160
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
8 zmienionych plików z 49 dodań i 37 usunięć

Wyświetl plik

@ -13,7 +13,7 @@ LANG=en_US.UTF-8
# locale filter to include in the locale generator # locale filter to include in the locale generator
LANGS="en_US.UTF-8,id_ID.UTF-8" LANGS="en_US.UTF-8,id_ID.UTF-8"
POSTGRES_MAJOR_VERSION=14 POSTGRES_MAJOR_VERSION=15
POSTGIS_MAJOR_VERSION=3 POSTGIS_MAJOR_VERSION=3
POSTGIS_MINOR_RELEASE=3 POSTGIS_MINOR_RELEASE=3
BUILD_TIMESCALE=true BUILD_TIMESCALE=true

Wyświetl plik

@ -27,7 +27,7 @@ jobs:
strategy: strategy:
matrix: matrix:
postgresMajorVersion: postgresMajorVersion:
- 14 - 15
postgisMajorVersion: postgisMajorVersion:
- 3 - 3
postgisMinorRelease: postgisMinorRelease:
@ -43,14 +43,14 @@ jobs:
imageVersion: bullseye imageVersion: bullseye
imageVariant: slim imageVariant: slim
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
- name: Build image for testing - name: Build image for testing
id: docker_build_testing_image id: docker_build_testing_image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v3
with: with:
context: . context: .
file: Dockerfile file: Dockerfile
@ -88,7 +88,7 @@ jobs:
strategy: strategy:
matrix: matrix:
postgresMajorVersion: postgresMajorVersion:
- 14 - 15
postgisMajorVersion: postgisMajorVersion:
- 3 - 3
postgisMinorRelease: postgisMinorRelease:
@ -98,7 +98,7 @@ jobs:
imageVersion: bullseye imageVersion: bullseye
imageVariant: slim imageVariant: slim
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
@ -120,7 +120,7 @@ jobs:
- name: Build image for testing - name: Build image for testing
id: docker_build_testing_image id: docker_build_testing_image
uses: docker/build-push-action@v2 uses: docker/build-push-action@v3
with: with:
context: . context: .
file: Dockerfile file: Dockerfile

Wyświetl plik

@ -29,7 +29,7 @@ jobs:
strategy: strategy:
matrix: matrix:
postgresMajorVersion: postgresMajorVersion:
- 14 - 15
postgisMajorVersion: postgisMajorVersion:
- 3 - 3
postgisMinorRelease: postgisMinorRelease:
@ -39,7 +39,7 @@ jobs:
imageVersion: bullseye imageVersion: bullseye
imageVariant: slim imageVariant: slim
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
@ -61,7 +61,7 @@ jobs:
- name: Build base image - name: Build base image
id: docker_build_base id: docker_build_base
uses: docker/build-push-action@v2 uses: docker/build-push-action@v3
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
@ -87,7 +87,7 @@ jobs:
- name: Build prod image - name: Build prod image
id: docker_build_prod id: docker_build_prod
uses: docker/build-push-action@v2 uses: docker/build-push-action@v3
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64

Wyświetl plik

@ -68,9 +68,9 @@ FROM postgis-base AS postgis-prod
# Reset ARG for version # Reset ARG for version
ARG IMAGE_VERSION ARG IMAGE_VERSION
ARG POSTGRES_MAJOR_VERSION=14 ARG POSTGRES_MAJOR_VERSION=15
ARG POSTGIS_MAJOR_VERSION=3 ARG POSTGIS_MAJOR_VERSION=3
ARG POSTGIS_MINOR_RELEASE=2 ARG POSTGIS_MINOR_RELEASE=3
ARG TIMESCALE_VERSION=2-2.7.2 ARG TIMESCALE_VERSION=2-2.7.2
ARG BUILD_TIMESCALE=false ARG BUILD_TIMESCALE=false
@ -92,6 +92,7 @@ RUN set -eux \
# We add postgis as well to prevent build errors (that we dont see on local builds) # We add postgis as well to prevent build errors (that we dont see on local builds)
# on docker hub e.g. # on docker hub e.g.
# The following packages have unmet dependencies: # The following packages have unmet dependencies:
#TODO add postgresql-${POSTGRES_MAJOR_VERSION}-cron back when it's available
RUN set -eux \ RUN set -eux \
&& export DEBIAN_FRONTEND=noninteractive \ && export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \ && apt-get update \
@ -101,7 +102,7 @@ RUN set -eux \
netcat postgresql-${POSTGRES_MAJOR_VERSION}-ogr-fdw \ netcat postgresql-${POSTGRES_MAJOR_VERSION}-ogr-fdw \
postgresql-${POSTGRES_MAJOR_VERSION}-postgis-${POSTGIS_MAJOR_VERSION}-scripts \ postgresql-${POSTGRES_MAJOR_VERSION}-postgis-${POSTGIS_MAJOR_VERSION}-scripts \
postgresql-plpython3-${POSTGRES_MAJOR_VERSION} postgresql-${POSTGRES_MAJOR_VERSION}-pgrouting \ postgresql-plpython3-${POSTGRES_MAJOR_VERSION} postgresql-${POSTGRES_MAJOR_VERSION}-pgrouting \
postgresql-server-dev-${POSTGRES_MAJOR_VERSION} postgresql-${POSTGRES_MAJOR_VERSION}-cron \ postgresql-server-dev-${POSTGRES_MAJOR_VERSION} \
postgresql-${POSTGRES_MAJOR_VERSION}-mysql-fdw postgresql-${POSTGRES_MAJOR_VERSION}-mysql-fdw
# TODO a case insensitive match would be more robust # TODO a case insensitive match would be more robust

Wyświetl plik

@ -7,7 +7,7 @@ volumes:
services: services:
db: db:
image: kartoza/postgis:14-3.2 image: kartoza/postgis:15-3.3
volumes: volumes:
- postgis-data:/var/lib/postgresql - postgis-data:/var/lib/postgresql
- dbbackups:/backups - dbbackups:/backups
@ -20,13 +20,13 @@ services:
# Add extensions you need to be enabled by default in the DB. Default are the five specified below # Add extensions you need to be enabled by default in the DB. Default are the five specified below
- POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting - POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting
ports: ports:
- "25432:5432" - "5432"
restart: on-failure restart: on-failure
healthcheck: healthcheck:
test: "exit 0" test: "exit 0"
dbbackups: dbbackups:
image: kartoza/pg-backup:14-3.2 image: kartoza/pg-backup:15-3.3
hostname: pg-backups hostname: pg-backups
volumes: volumes:
- dbbackups:/backups - dbbackups:/backups

Wyświetl plik

@ -329,9 +329,9 @@ fi
if [ -z "${SHARED_PRELOAD_LIBRARIES}" ]; then if [ -z "${SHARED_PRELOAD_LIBRARIES}" ]; then
if [[ $(dpkg -l | grep "timescaledb") > /dev/null ]];then if [[ $(dpkg -l | grep "timescaledb") > /dev/null ]];then
SHARED_PRELOAD_LIBRARIES='pg_cron,timescaledb' SHARED_PRELOAD_LIBRARIES='timescaledb'
else #else
SHARED_PRELOAD_LIBRARIES='pg_cron' #SHARED_PRELOAD_LIBRARIES='pg_cron'cron
fi fi
fi fi
@ -474,4 +474,23 @@ until su - postgres -c "${PG_BASEBACKUP} -X stream -h ${REPLICATE_FROM} -p ${REP
} }
function over_write_conf() {
if [[ -f ${ROOT_CONF}/postgis.conf ]];then
sed -i '/postgis.conf/d' "${ROOT_CONF}"/postgresql.conf
cat "${ROOT_CONF}"/postgis.conf >> "${ROOT_CONF}"/postgresql.conf
fi
if [[ -f ${ROOT_CONF}/logical_replication.conf ]];then
sed -i '/logical_replication.conf/d' "${ROOT_CONF}"/postgresql.conf
cat "${ROOT_CONF}"/logical_replication.conf >> "${ROOT_CONF}"/postgresql.conf
fi
if [[ -f ${ROOT_CONF}/streaming_replication.conf ]];then
sed -i '/streaming_replication.conf/d' "${ROOT_CONF}"/postgresql.conf
cat "${ROOT_CONF}"/streaming_replication.conf >> "${ROOT_CONF}"/postgresql.conf
fi
if [[ -f ${ROOT_CONF}/extra.conf ]];then
sed -i '/extra.conf/d' "${ROOT_CONF}"/postgresql.conf
cat "${ROOT_CONF}"/extra.conf >> "${ROOT_CONF}"/postgresql.conf
fi
}

Wyświetl plik

@ -101,28 +101,20 @@ fi
# Timescale default tuning # Timescale default tuning
# TODO If timescale DB accepts reading from include directory then refactor code to remove line 97 - 112 (https://github.com/timescale/timescaledb-tune/issues/80) # TODO If timescale DB accepts reading from include directory then refactor code to remove line 97 - 112 (https://github.com/timescale/timescaledb-tune/issues/80)
if [[ $(dpkg -l | grep "timescaledb") > /dev/null ]] && [[ ${ACCEPT_TIMESCALE_TUNING} =~ [Tt][Rr][Uu][Ee] ]] ;then if [[ $(dpkg -l | grep "timescaledb") > /dev/null ]] && [[ ${ACCEPT_TIMESCALE_TUNING} =~ [Tt][Rr][Uu][Ee] ]] ;then
if [[ -f ${ROOT_CONF}/postgis.conf ]];then over_write_conf
sed -i '/postgis.conf/d' "${ROOT_CONF}"/postgresql.conf
cat "${ROOT_CONF}"/postgis.conf >> "${ROOT_CONF}"/postgresql.conf
fi
if [[ -f ${ROOT_CONF}/logical_replication.conf ]];then
sed -i '/logical_replication.conf/d' "${ROOT_CONF}"/postgresql.conf
cat "${ROOT_CONF}"/logical_replication.conf >> "${ROOT_CONF}"/postgresql.conf
fi
if [[ -f ${ROOT_CONF}/streaming_replication.conf ]];then
sed -i '/streaming_replication.conf/d' "${ROOT_CONF}"/postgresql.conf
cat "${ROOT_CONF}"/streaming_replication.conf >> "${ROOT_CONF}"/postgresql.conf
fi
if [[ -f ${ROOT_CONF}/extra.conf ]];then
sed -i '/extra.conf/d' "${ROOT_CONF}"/postgresql.conf
cat "${ROOT_CONF}"/extra.conf >> "${ROOT_CONF}"/postgresql.conf
fi
echo -e "\e[1;31m Time scale config tuning values below" echo -e "\e[1;31m Time scale config tuning values below"
# TODO Add logic to find defaults memory, CPUS as these can vary from defaults on host machine and in docker container # TODO Add logic to find defaults memory, CPUS as these can vary from defaults on host machine and in docker container
timescaledb-tune -yes -quiet "${TIMESCALE_TUNING_PARAMS}" --conf-path="${ROOT_CONF}"/postgresql.conf timescaledb-tune -yes -quiet "${TIMESCALE_TUNING_PARAMS}" --conf-path="${ROOT_CONF}"/postgresql.conf
echo -e "\033[0m Time scale config tuning values set in ${ROOT_CONF}/postgresql.conf" echo -e "\033[0m Time scale config tuning values set in ${ROOT_CONF}/postgresql.conf"
elif [[ ${ACCEPT_TIMESCALE_TUNING} =~ [Tt][Rr][Uu][Ee] ]]; then
echo -e "\e[1;31m Time scale config tuning values below"
timescaledb-tune -yes -quiet "${TIMESCALE_TUNING_PARAMS}" --conf-path="${ROOT_CONF}"/time_scale_tuning.conf
echo -e "\033[0m Time scale config tuning values set in ${ROOT_CONF}/time_scale_tuning.conf"
fi fi
# Optimise PostgreSQL shared memory for PostGIS # Optimise PostgreSQL shared memory for PostGIS
# shmall units are pages and shmmax units are bytes(?) equivalent to the desired shared_buffer size set in setup_conf.sh - in this case 500MB # shmall units are pages and shmmax units are bytes(?) equivalent to the desired shared_buffer size set in setup_conf.sh - in this case 500MB
echo "kernel.shmmax=543252480" >> /etc/sysctl.conf echo "kernel.shmmax=543252480" >> /etc/sysctl.conf

Wyświetl plik

@ -110,7 +110,7 @@ for db in $(echo ${POSTGRES_DBNAME} | tr ',' ' '); do
if [[ ${RESULT} -eq 0 ]]; then if [[ ${RESULT} -eq 0 ]]; then
echo "Create db ${db}" echo "Create db ${db}"
su - postgres -c "createdb -O ${POSTGRES_USER} ${db}" su - postgres -c "createdb -O ${POSTGRES_USER} ${db}"
su - postgres -c "psql -c 'CREATE EXTENSION IF NOT EXISTS pg_cron cascade;' ${SINGLE_DB}" #su - postgres -c "psql -c 'CREATE EXTENSION IF NOT EXISTS pg_cron cascade;' ${SINGLE_DB}"
for ext in $(echo ${POSTGRES_MULTIPLE_EXTENSIONS} | tr ',' ' '); do for ext in $(echo ${POSTGRES_MULTIPLE_EXTENSIONS} | tr ',' ' '); do
echo "Enabling \"${ext}\" in the database ${db}" echo "Enabling \"${ext}\" in the database ${db}"
if [[ ${ext} != 'pg_cron' ]]; then if [[ ${ext} != 'pg_cron' ]]; then