postgres shadow
Build and Push Docker Images / build-and-push (push) Failing after 22s

This commit is contained in:
2025-05-21 20:54:15 +02:00
parent c8ec96d448
commit 4e237f1737
2 changed files with 45 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
set -e
# Wait for PostgreSQL to be ready
until pg_isready; do
echo "Waiting for PostgreSQL to be ready..."
sleep 2
done
# Create the target database
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE DATABASE $TARGET_DB_NAME;
EOSQL
# Copy the database if SOURCE_DB_URL is provided
if [ ! -z "$SOURCE_DB_URL" ]; then
echo "Copying database from $SOURCE_DB_URL to $TARGET_DB_NAME..."
# Dump the source database
pg_dump "$SOURCE_DB_URL" | psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$TARGET_DB_NAME"
echo "Database copy completed successfully"
else
echo "No SOURCE_DB_URL provided, skipping database copy"
fi