Skip to content

Commit 75a43f2

Browse files
authored
Merge pull request #5 from MEITREX/db
Database: Update init script & increase max connections
2 parents 8f623dc + eb986c0 commit 75a43f2

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
services:
22
database:
33
image: pgvector/pgvector:pg16
4+
command: -c 'max_connections=500'
45
restart: unless-stopped
56
expose:
67
- 5432
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Script taken with modifications from https://dev.to/bgord/multiple-postgres-databases-in-a-single-docker-container-417l
4+
5+
set -e
6+
set -u
7+
8+
function create_user_and_database() {
9+
local database=$1
10+
echo " Creating user and database '$database'"
11+
psql -d postgres -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
12+
CREATE DATABASE "$database";
13+
GRANT ALL PRIVILEGES ON DATABASE "$database" TO "$POSTGRES_USER";
14+
EOSQL
15+
}
16+
17+
for var in $(env | grep '^POSTGRES_CREATE_DB_' | awk -F '=' '{print $2}'); do
18+
echo "Creating database: $var"
19+
create_user_and_database $var
20+
done

0 commit comments

Comments
 (0)