Skip to content

Commit 7bb6553

Browse files
committed
feat: Create a small bash script for launching Postgres using Docker
1 parent cfde571 commit 7bb6553

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

scripts/init_db.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -x
3+
set -eo pipefail
4+
5+
# Check if a custom user has been set, otherwise default to 'postgres'
6+
DB_USER=${POSTGRES_USER:=postgres}
7+
# Check if a custom password has been set, otherwise default to 'password'
8+
DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
9+
# Check if a custom database name has been set, otherwise default to 'bibimbap'
10+
DB_NAME="${POSTGRES_DB:=bibimbap}"
11+
# Check if a custom port has been set, otherwise default to '5432'
12+
DB_PORT="${POSTGRES_PORT:=5432}"
13+
# Check if a custom host has been set, otherwise default to 'localhost'
14+
DB_HOST="${POSTGRES_HOST:=localhost}"
15+
16+
# Launch Postgres using Docker
17+
docker run \
18+
-e POSTGRES_USER=${DB_USER} \
19+
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
20+
-e POSTGRES_DB=${DB_NAME} \
21+
-p "${DB_PORT}":5432 \
22+
-d postgres \
23+
postgres -N 1000
24+
# ^ Increased maximum number of connections for testing purposes

0 commit comments

Comments
 (0)