File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11services :
22 database :
33 image : pgvector/pgvector:pg16
4+ command : -c 'max_connections=500'
45 restart : unless-stopped
56 expose :
67 - 5432
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments