Fork of github.com/did-method-plc/did-method-plc
1#!/usr/bin/env sh
2
3# Example usage:
4# ./with-test-db.sh psql postgresql://pg:password@localhost:5433/postgres -c 'select 1;'
5
6dir=$(dirname $0)
7compose_file="$dir/docker-compose.yaml"
8
9docker compose -f $compose_file up --wait --force-recreate db_test
10echo # newline
11
12trap on_sigint INT
13on_sigint() {
14 echo # newline
15 docker compose -f $compose_file rm -f --stop --volumes db_test
16 exit $?
17}
18
19# Based on creds in compose.yaml
20export PGPORT=5433
21export PGHOST=localhost
22export PGUSER=pg
23export PGPASSWORD=password
24export PGDATABASE=postgres
25export DATABASE_URL="postgresql://pg:password@localhost:5433/postgres"
26"$@"
27code=$?
28
29echo # newline
30docker compose -f $compose_file rm -f --stop --volumes db_test
31
32exit $code