File tree Expand file tree Collapse file tree
postgres/docker-entrypoint-initdb.d Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -322,6 +322,7 @@ services:
322322 build : ./postgres
323323 volumes :
324324 - ${DATA_PATH_HOST}/postgres:/var/lib/postgresql/data
325+ - ${POSTGRES_ENTRYPOINT_INITDB}:/docker-entrypoint-initdb.d
325326 ports :
326327 - " ${POSTGRES_PORT}:5432"
327328 environment :
Original file line number Diff line number Diff line change 1+ * .sh
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ #
3+ # Copy createdb.sh.example to createdb.sh
4+ # then uncomment then set database name and username to create you need databases
5+ #
6+ # example: .env POSTGRES_USER=appuser and need db name is myshop_db
7+ #
8+ # psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
9+ # CREATE USER myuser WITH PASSWORD 'mypassword';
10+ # CREATE DATABASE myshop_db;
11+ # GRANT ALL PRIVILEGES ON DATABASE myshop_db TO myuser;
12+ # EOSQL
13+ #
14+ # this sh script will auto run when the postgres container starts and the $DATA_PATH_HOST/postgres not found.
15+ #
16+
17+ set -e
18+ # psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
19+ # CREATE USER db1 WITH PASSWORD 'db1';
20+ # CREATE DATABASE db1;
21+ # GRANT ALL PRIVILEGES ON DATABASE db1 TO db1;
22+ # EOSQL
23+
24+ # psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
25+ # CREATE USER db2 WITH PASSWORD 'db2';
26+ # CREATE DATABASE db2;
27+ # GRANT ALL PRIVILEGES ON DATABASE db2 TO db2;
28+ # EOSQL
29+
30+ # psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
31+ # CREATE USER db3 WITH PASSWORD 'db3';
32+ # CREATE DATABASE db3;
33+ # GRANT ALL PRIVILEGES ON DATABASE db3 TO db3;
34+ # EOSQL
You can’t perform that action at this time.
0 commit comments