Skip to content

Commit 1a7e915

Browse files
committed
Move load-db.sh to use docker
1 parent c781b55 commit 1a7e915

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

scripts/load-db.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@
1616

1717
set -eu
1818
IMPORT_FILE=$1
19+
20+
POSTGRES_IMAGE="postgres:16.3-alpine"
21+
1922
docker rm -f spi_dev
20-
docker run --name spi_dev -e POSTGRES_DB=spi_dev -e POSTGRES_USER=spi_dev -e POSTGRES_PASSWORD=xxx -p 6432:5432 -d postgres:16.3-alpine
23+
docker run --name spi_dev -e POSTGRES_DB=spi_dev -e POSTGRES_USER=spi_dev -e POSTGRES_PASSWORD=xxx -p 6432:5432 -d $POSTGRES_IMAGE
2124
echo "Giving Postgres a moment to launch ..."
2225
sleep 5
26+
2327
echo "Creating Azure roles"
24-
PGPASSWORD=xxx psql -h "${HOST:-localhost}" -p 6432 -U spi_dev -d spi_dev -c 'CREATE ROLE azure_pg_admin; CREATE ROLE azuresu;'
28+
psql="docker run --rm -v $PWD:/host -w /host --network=host -e PGPASSWORD=xxx $POSTGRES_IMAGE psql"
29+
$psql -h "${HOST:-localhost}" -p 6432 -U spi_dev -d spi_dev -c 'CREATE ROLE azure_pg_admin; CREATE ROLE azuresu;'
30+
2531
echo "Importing"
26-
PGPASSWORD=xxx pg_restore --no-owner -h "${HOST:-localhost}" -p 6432 -U spi_dev -d spi_dev < "$IMPORT_FILE"
32+
pg_restore="docker run --rm -i -v $PWD:/host -w /host --network=host -e PGPASSWORD=xxx $POSTGRES_IMAGE pg_restore"
33+
$pg_restore --no-owner -h "${HOST:-localhost}" -p 6432 -U spi_dev -d spi_dev < "$IMPORT_FILE"

0 commit comments

Comments
 (0)