diff --git a/.example.env b/.example.env index 4793d529..b4088802 100644 --- a/.example.env +++ b/.example.env @@ -15,5 +15,5 @@ LANGS="en_US.UTF-8,id_ID.UTF-8" POSTGRES_MAJOR_VERSION=15 POSTGIS_MAJOR_VERSION=3 -POSTGIS_MINOR_RELEASE=3 +POSTGIS_MINOR_RELEASE=4 BUILD_TIMESCALE=false \ No newline at end of file diff --git a/.github/workflows/build-latest.yaml b/.github/workflows/build-latest.yaml index 8d15d069..27b984ce 100644 --- a/.github/workflows/build-latest.yaml +++ b/.github/workflows/build-latest.yaml @@ -31,7 +31,7 @@ jobs: postgisMajorVersion: - 3 postgisMinorRelease: - - 3 + - 4 scenario: - datadir_init - streaming_replication @@ -93,7 +93,7 @@ jobs: postgisMajorVersion: - 3 postgisMinorRelease: - - 3 + - 4 include: - distro: debian imageVersion: bookworm diff --git a/.github/workflows/deploy-image.yaml b/.github/workflows/deploy-image.yaml index f7849f01..da6712f6 100644 --- a/.github/workflows/deploy-image.yaml +++ b/.github/workflows/deploy-image.yaml @@ -33,7 +33,7 @@ jobs: postgisMajorVersion: - 3 postgisMinorRelease: - - 3 + - 4 include: - distro: debian imageVersion: bookworm diff --git a/Dockerfile b/Dockerfile index 9fbcb186..0b288413 100644 --- a/Dockerfile +++ b/Dockerfile @@ -74,7 +74,7 @@ FROM postgis-base AS postgis-prod ARG IMAGE_VERSION ARG POSTGRES_MAJOR_VERSION=15 ARG POSTGIS_MAJOR_VERSION=3 -ARG POSTGIS_MINOR_RELEASE=3 +ARG POSTGIS_MINOR_RELEASE=4 ARG TIMESCALE_VERSION=2-2.9.1 ARG BUILD_TIMESCALE=false @@ -119,9 +119,8 @@ RUN if [ "${BUILD_TIMESCALE}" = "true" ]; then \ apt-get -y --no-install-recommends install timescaledb-${TIMESCALE_VERSION}-postgresql-${POSTGRES_MAJOR_VERSION} timescaledb-tools;\ fi; -RUN echo $POSTGRES_MAJOR_VERSION >/tmp/pg_version.txt -RUN echo $POSTGIS_MAJOR_VERSION >/tmp/pg_major_version.txt -RUN echo $POSTGIS_MINOR_RELEASE >/tmp/pg_minor_version.txt +RUN echo $POSTGRES_MAJOR_VERSION >/tmp/pg_version.txt && echo $POSTGIS_MAJOR_VERSION >/tmp/pg_major_version.txt && \ + echo $POSTGIS_MINOR_RELEASE >/tmp/pg_minor_version.txt ENV \ PATH="$PATH:/usr/lib/postgresql/${POSTGRES_MAJOR_VERSION}/bin" # Compile pointcloud extension @@ -131,8 +130,6 @@ cd pointcloud-master && \ ./autogen.sh && ./configure && make -j 4 && make install && \ cd .. && rm -Rf pointcloud-master - - # Cleanup resources RUN apt-get -y --purge autoremove \ && apt-get clean \ diff --git a/docker-compose.yml b/docker-compose.yml index 4171c027..cf526fe4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ volumes: services: db: - image: kartoza/postgis:15-3.3 + image: kartoza/postgis:${POSTGRES_MAJOR_VERSION}-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_RELEASE} volumes: - postgis-data:/var/lib/postgresql - dbbackups:/backups @@ -28,7 +28,7 @@ services: dbbackups: - image: kartoza/pg-backup:15-3.3 + image: kartoza/pg-backup:${POSTGRES_MAJOR_VERSION}-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_RELEASE} hostname: pg-backups volumes: - dbbackups:/backups diff --git a/scripts/env-data.sh b/scripts/env-data.sh index 457e2175..2f7247b1 100644 --- a/scripts/env-data.sh +++ b/scripts/env-data.sh @@ -515,6 +515,7 @@ function over_write_conf() { } + function extension_install() { DATABASE=$1 IFS=':' @@ -550,6 +551,7 @@ function extension_install() { fi } + function directory_checker() { DATA_PATH=$1 if [ -d $DATA_PATH ];then @@ -578,3 +580,13 @@ function non_root_permission() { } +function role_check() { + ROLE_NAME=$1 + echo "Creating user $1" + RESULT=$(su - postgres -c "psql postgres -t -c \"SELECT 1 FROM pg_roles WHERE rolname = '$ROLE_NAME'\"") + COMMAND="ALTER" + if [ -z "$RESULT" ]; then + export COMMAND="CREATE" + fi + +} diff --git a/scripts/setup-user.sh b/scripts/setup-user.sh index 52d1c486..502fbd77 100644 --- a/scripts/setup-user.sh +++ b/scripts/setup-user.sh @@ -4,32 +4,12 @@ source /scripts/env-data.sh # This script will setup new configured user -# Note that $POSTGRES_USER and $POSTGRES_PASS below are optional parameters that can be passed -# via docker run e.g. -#docker run --name="postgis" -e POSTGRES_USER=qgis -e POSTGRES_PASS=qgis -d -v -#/var/docker-data/postgres-dat:/var/lib/postgresql -t qgis/postgis:6 - -# If you dont specify a user/password in docker run, we will generate one -# here and create a user called 'docker' to go with it. - -# Only create credentials if this is a master database -# Slave database will just mirror from master users - # Check user already exists -echo "Creating superuser $POSTGRES_USER" -RESULT=`su - postgres -c "psql postgres -t -c \"SELECT 1 FROM pg_roles WHERE rolname = '$POSTGRES_USER'\""` -COMMAND="ALTER" -if [ -z "$RESULT" ]; then - COMMAND="CREATE" -fi + +role_check $POSTGRES_USER su - postgres -c "psql postgres -c \"$COMMAND USER $POSTGRES_USER WITH SUPERUSER ENCRYPTED PASSWORD '$POSTGRES_PASS';\"" -echo "Creating replication user $REPLICATION_USER" -RESULT_REPLICATION=`su - postgres -c "psql postgres -t -c \"SELECT 1 FROM pg_roles WHERE rolname = '$REPLICATION_USER'\""` -COMMANDS="ALTER" -if [ -z "$RESULT_REPLICATION" ]; then - COMMANDS="CREATE" -fi -su - postgres -c "psql postgres -c \"$COMMANDS USER $REPLICATION_USER WITH REPLICATION ENCRYPTED PASSWORD '$REPLICATION_PASS';\"" +role_check $REPLICATION_USER +su - postgres -c "psql postgres -c \"$COMMAND USER $REPLICATION_USER WITH REPLICATION ENCRYPTED PASSWORD '$REPLICATION_PASS';\""