#!/bin/bash CONTAINER_NAME="pra-db" SQL_FILE="init_db.sql" docker-compose up -d # Copy the SQL file to the container docker cp $SQL_FILE $CONTAINER_NAME:/init_db.sql # Wait until the PostgreSQL server is ready echo "Waiting for PostgreSQL to become available..." until docker exec $CONTAINER_NAME pg_isready -U devuser -d pra_db > /dev/null 2>&1; do sleep 1 done echo "PostgreSQL is available now." # Execute the SQL file inside the container docker exec -it $CONTAINER_NAME sh -c "psql -U devuser -d pra_db -f /init_db.sql"