Reviewed-on: #1 Co-authored-by: Gabriel Sancho <gabriel.sancho13@gmail.com> Co-committed-by: Gabriel Sancho <gabriel.sancho13@gmail.com> Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
APP_DB_NAME=${APP_DB_NAME:-condado}
|
||||
APP_DB_USER=${SPRING_DATASOURCE_USERNAME:-condado}
|
||||
APP_DB_PASSWORD=${SPRING_DATASOURCE_PASSWORD:-condado}
|
||||
|
||||
# ── Initialise PostgreSQL data directory on first run ─────────────────────────
|
||||
if [ ! -f /var/lib/postgresql/data/PG_VERSION ]; then
|
||||
echo "Initialising PostgreSQL data directory..."
|
||||
@@ -9,8 +13,8 @@ if [ ! -f /var/lib/postgresql/data/PG_VERSION ]; then
|
||||
# Start postgres temporarily to create the app database and user
|
||||
su -c "/usr/lib/postgresql/16/bin/pg_ctl -D /var/lib/postgresql/data -w start" postgres
|
||||
|
||||
su -c "psql -c \"CREATE USER condado WITH PASSWORD 'condado';\"" postgres
|
||||
su -c "psql -c \"CREATE DATABASE condado OWNER condado;\"" postgres
|
||||
su -c "psql -v ON_ERROR_STOP=1 -c \"CREATE USER ${APP_DB_USER} WITH PASSWORD '${APP_DB_PASSWORD}';\"" postgres
|
||||
su -c "psql -v ON_ERROR_STOP=1 -c \"CREATE DATABASE ${APP_DB_NAME} OWNER ${APP_DB_USER};\"" postgres
|
||||
|
||||
su -c "/usr/lib/postgresql/16/bin/pg_ctl -D /var/lib/postgresql/data -w stop" postgres
|
||||
echo "PostgreSQL initialised."
|
||||
@@ -20,9 +24,9 @@ fi
|
||||
mkdir -p /var/log/supervisor
|
||||
|
||||
# ── Defaults for all-in-one local PostgreSQL ─────────────────────────────────
|
||||
export SPRING_DATASOURCE_URL=${SPRING_DATASOURCE_URL:-jdbc:postgresql://localhost:5432/condado}
|
||||
export SPRING_DATASOURCE_USERNAME=${SPRING_DATASOURCE_USERNAME:-condado}
|
||||
export SPRING_DATASOURCE_PASSWORD=${SPRING_DATASOURCE_PASSWORD:-condado}
|
||||
export SPRING_DATASOURCE_URL=${SPRING_DATASOURCE_URL:-jdbc:postgresql://localhost:5432/${APP_DB_NAME}}
|
||||
export SPRING_DATASOURCE_USERNAME=${SPRING_DATASOURCE_USERNAME:-${APP_DB_USER}}
|
||||
export SPRING_DATASOURCE_PASSWORD=${SPRING_DATASOURCE_PASSWORD:-${APP_DB_PASSWORD}}
|
||||
|
||||
# ── Start all services via supervisord ───────────────────────────────────────
|
||||
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||
|
||||
Reference in New Issue
Block a user