refactor: update build process to create a single all-in-one Docker image and adjust related configurations
Some checks failed
CI / Frontend Tests (pull_request) Has been cancelled
CI / Backend Tests (pull_request) Has been cancelled

This commit is contained in:
2026-03-27 16:10:14 -03:00
parent 3f0bb4be73
commit 6305a8e95e
6 changed files with 42 additions and 64 deletions

View File

@@ -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