- Add "ALTER DATABASE" in postsql to change database owner to POSTGRESQL_USER,

- Update env.dist & compose files to fully support docker_service_add Docker Tools function.
This commit is contained in:
Arnaud G. GIBERT 2025-03-10 18:15:39 +01:00
parent 97cddb4723
commit 1de308fdb9
4 changed files with 56 additions and 46 deletions

View File

@ -48,6 +48,7 @@ then
\n\
if [[ -n "${POSTGRESQL_DATABASE}" ]] \n\
then \n\
echo "ALTER DATABASE \"${POSTGRESQL_DATABASE}\" OWNER TO \"${POSTGRESQL_USER}\";" >>/tmp/post.sql \n\
echo "GRANT ALL PRIVILEGES ON DATABASE \"${POSTGRESQL_DATABASE}\" TO \"${POSTGRESQL_USER}\";" >>/tmp/post.sql \n\
fi \n\
fi \n\

View File

@ -1,3 +1,12 @@
------------------------------------------------------------------------------------------------------------------------------------
Rx3-Docker/PostgreSQL V 1.1.2 - A. GIBERT - 2025/03/10
------------------------------------------------------------------------------------------------------------------------------------
- Add "ALTER DATABASE" in postsql to change database owner to POSTGRESQL_USER,
- Update env.dist & compose files to fully support docker_service_add Docker Tools function.
------------------------------------------------------------------------------------------------------------------------------------
Rx3-Docker/PostgreSQL V 1.1.1 - A. GIBERT - 2025/03/08
------------------------------------------------------------------------------------------------------------------------------------

View File

@ -1,35 +1,36 @@
# Rx3-Docker/PostgreSQL Docker Image
#-------------------------------------------------------------------------------
name: ${IMG_NAME}
name: ${DATABASE_IMG_NAME}
services:
database:
container_name: ${IMG_NAME}
hostname: ${IMG_NAME}
image: ${IMG_URL}
container_name: ${DATABASE_IMG_NAME}
hostname: ${DATABASE_IMG_NAME}
image: ${DATABASE_IMG_URL}
build:
context: .
args:
IMG_NAME: ${IMG_NAME}
IMG_NAME_FULL: ${IMG_NAME_FULL}
IMG_VERSION: ${IMG_VERSION}
IMG_MAINTAINER: ${IMG_MAINTAINER}
IMG_FROM_URL: ${IMG_FROM_URL}
IMG_NAME: ${DATABASE_IMG_NAME}
IMG_NAME_FULL: ${DATABASE_IMG_NAME_FULL}
IMG_VERSION: ${DATABASE_IMG_VERSION}
IMG_MAINTAINER: ${DATABASE_IMG_MAINTAINER}
IMG_FROM_URL: ${DATABASE_IMG_FROM_URL}
POSTGRESQL_LIB: ${DATABASE_LIB_DIR}
POSTGRESQL_LOG: ${DATABASE_LOG_POSTGRES_DIR}
POSTGRESQL_LIB: ${DATABASE_LIB_INT}
POSTGRESQL_LOG: ${DATABASE_LOG_MAIN_INT}
POSTGRESQL_PORT: ${DATABASE_PORT_MAIN_INT}
POSTSQL_LOG_DIR: ${DATABASE_LOG_POSTSQL_DIR}
POSTSQL_LOG_DIR: ${DATABASE_LOG_INIT_INT}
restart: unless-stopped
environment:
POSTGRESQL_UID: ${POSTGRESQL_UID}
POSTGRESQL_GID: ${POSTGRESQL_GID}
POSTGRESQL_UID: ${DATABASE_USER_ID}
POSTGRESQL_GID: ${DATABASE_GROUP_ID}
POSTGRESQL_POSTGRES_PASSWORD: ${POSTGRESQL_POSTGRES_PASSWORD}
POSTGRESQL_DATABASE: ${POSTGRESQL_DATABASE}
POSTGRESQL_USER: ${POSTGRESQL_USER}
@ -42,11 +43,11 @@ services:
retries: 3
volumes:
- ./var/lib/pgsql/data:${DATABASE_DATA_DIR}
- ./var/log/init:${DATABASE_LOG_INIT_DIR}
- ./var/log/supervisor:${DATABASE_LOG_SV_DIR}
- ./var/log/postgres:${DATABASE_LOG_POSTGRES_DIR}
- ./${DATABASE_LIB_EXT}:${DATABASE_LIB_INT}
- ./${DATABASE_LOG_INIT_EXT}:${DATABASE_LOG_INIT_INT}
- ./${DATABASE_LOG_SV_EXT}:${DATABASE_LOG_SV_INT}
- ./${DATABASE_LOG_MAIN_EXT}:${DATABASE_LOG_MAIN_INT}
ports:
- "127.0.0.1:${DATABASE_PORT_SV_EXT}:${DATABASE_PORT_SV_INT}"
- "127.0.0.1:${DATABASE_PORT_MAIN_EXT}:${DATABASE_PORT_MAIN_INT}"

View File

@ -7,6 +7,7 @@
ORG_NAME="rx3-docker"
ORG_REGISTRY="docker.xor.rx3:5000"
ORG_MAINTAINER='"Arnaud G. GIBERT" <arnaud@rx3.net>'
ORG_URL_PREFIX="${ORG_REGISTRY}/${ORG_NAME}"
@ -16,40 +17,38 @@ ORG_URL_PREFIX="${ORG_REGISTRY}/${ORG_NAME}"
# Image Settings
#-------------------------------------------------------------------------------
IMG_NAME="postgresql"
IMG_NAME_FULL="Rx3-Docker/PostgreSQL Docker Image"
IMG_VERSION="1.1.1-mga9"
IMG_MAINTAINER='"Arnaud G. GIBERT" <arnaud@rx3.net>'
HOST_NAME_PREFIX=""
IMG_URL_PREFIX="${ORG_URL_PREFIX}"
IMG_URL="${IMG_URL_PREFIX}/${IMG_NAME}:${IMG_VERSION}"
PORT_ENV_OFFSET=0
IMG_FROM_URL="${ORG_URL_PREFIX}/server:1.2.1-mga9"
PORT_SV_INT=9001
PORT_SV_OFFSET=1000
NETWORK_NAME=${HOST_NAME_PREFIX}
NETWORK_IF_NAME=br-${APPL_NAME_SHORT}-${APPL_ENV}
DOCKER_TOOLS_DEBUG=FALSE
DOCKER_TOOLS_VOLUME=SINGLE
#DOCKER_TOOLS_VOLUME=MIXED
#DOCKER_TOOLS_VOLUME=MERGED
#DOCKER_TOOLS_VOLUME=SPLIT
DOCKER_TOOLS_EXEPTION_LIBS="postgres:pgsql"
#------------------+----------+--------------------------+--------------------+------------------+-------------------------------+----------------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+
# | Variable | Service | Target Image | From Image | Module | Main Port | Admin Port | User | Group |
# | Prefix | Name | URL Prefix | Name | Name Full | Version | URL Prefix | Name | Version | Name | Version | Ext | Int | Ext | Int | Name / Id | Name / Id |
#------------------+----------+--------------------------+--------------------+------------------+-------------------------------+----------------------+--------------------+---------------+------------+--------------+------------+-------+-------+-------+-------+--------------+--------------+
docker_service_add DATABASE database ${ORG_URL_PREFIX} postgresql "Rx3-Docker/PostgreSQL" 1.1.2-mga9 ${ORG_URL_PREFIX} server 1.2.1-mga9 postgres - 8032 5432 - - 983 981
#-------------------------------------------------------------------------------
# User Settings
# Database
#-------------------------------------------------------------------------------
ENV_PORT_OFFSET=0
SV_PORT_OFFSET=1000
DATABASE_PORT_MAIN_EXT=$(( 8032 + ${ENV_PORT_OFFSET}))
DATABASE_PORT_MAIN_INT=5432
DATABASE_PORT_SV_EXT=$(( ${DATABASE_PORT_MAIN_EXT} + ${SV_PORT_OFFSET}))
DATABASE_PORT_SV_INT=9001
DATABASE_LIB_DIR="/var/lib/pgsql"
DATABASE_DATA_DIR="${DATABASE_LIB_DIR}/data"
DATABASE_LOG_INIT_DIR="/var/log/init"
DATABASE_LOG_SV_DIR="/var/log/supervisor"
DATABASE_LOG_POSTGRES_DIR="/var/log/postgres"
DATABASE_LOG_POSTSQL_DIR="${DATABASE_LOG_SV_DIR}"
POSTGRESQL_UID=971
POSTGRESQL_GID=971
POSTGRESQL_POSTGRES_PASSWORD="postgresadmin"
POSTGRESQL_DATABASE="test"
POSTGRESQL_USER="test"