Skip to content

Commit 0a245e5

Browse files
committed
feat: Update script to skip Docker if Postgres is already running
1 parent 870e446 commit 0a245e5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

scripts/init_db.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ DB_PORT="${POSTGRES_PORT:=5432}"
2323
DB_HOST="${POSTGRES_HOST:=localhost}"
2424

2525
# Launch Postgres using Docker
26-
docker run \
27-
-e POSTGRES_USER=${DB_USER} \
28-
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
29-
-e POSTGRES_DB=${DB_NAME} \
30-
-p "${DB_PORT}":5432 \
31-
-d postgres \
32-
postgres -N 1000
33-
# ^ Increased maximum number of connections for testing purposes
26+
# Allow to skip Docker if a dockerized Postgres database is already running
27+
if [[ -z "${SKIP_DOCKER}" ]]
28+
then
29+
docker run \
30+
-e POSTGRES_USER=${DB_USER} \
31+
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
32+
-e POSTGRES_DB=${DB_NAME} \
33+
-p "${DB_PORT}":5432 \
34+
-d postgres \
35+
postgres -N 1000
36+
fi
3437

3538
export PGPASSWORD="${DB_PASSWORD}"
3639
until psql -h "${DB_HOST}" -U "${DB_USER}" -p "${DB_PORT}" -d "postgres" -c '\q'; do

0 commit comments

Comments
 (0)