feat: multiple database and user in postgres
All checks were successful
CI / build (push) Successful in 11s
All checks were successful
CI / build (push) Successful in 11s
This commit is contained in:
5
postgres/Dockerfile
Normal file
5
postgres/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
||||
FROM postgres:latest
|
||||
|
||||
# Custom initialization scripts
|
||||
COPY ./create_user.sh /docker-entrypoint-initdb.d/10-create_user.sh
|
||||
COPY ./create_db.sh /docker-entrypoint-initdb.d/20-create_db.sh
|
17
postgres/create_db.sh
Normal file
17
postgres/create_db.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
POSTGRES="psql --username ${POSTGRES_USER}"
|
||||
|
||||
echo "Creating database: ${DB_NAME}"
|
||||
|
||||
$POSTGRES <<EOSQL
|
||||
CREATE DATABASE ${BACKEND_DB} OWNER ${BACKEND_USER};
|
||||
EOSQL
|
||||
|
||||
|
||||
echo "Creating database: ${DB_NAME}"
|
||||
|
||||
$POSTGRES <<EOSQL
|
||||
CREATE DATABASE ${KEYCLOAK_DB} OWNER ${KEYCLOAK_USER};
|
||||
EOSQL
|
16
postgres/create_user.sh
Normal file
16
postgres/create_user.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
POSTGRES="psql --username ${POSTGRES_USER}"
|
||||
|
||||
echo "Creating database role: [${BACKEND_USER}]"
|
||||
|
||||
$POSTGRES <<-EOSQL
|
||||
CREATE USER ${BACKEND_USER} WITH CREATEDB PASSWORD '${BACKEND_PASSWORD}';
|
||||
EOSQL
|
||||
|
||||
|
||||
echo "Creating database role: ${KEYCLOAK_USER}"
|
||||
$POSTGRES <<-EOSQL
|
||||
CREATE USER ${KEYCLOAK_USER} WITH CREATEDB PASSWORD '${KEYCLOAK_PASSWORD}';
|
||||
EOSQL
|
Reference in New Issue
Block a user