Simplify postgres setup

If POSTGRES_USER, POSTGRES_PASSWORD and POSTGRES_DB are set, the
postgres container automatically creates the database and role with the
set name and password.
This commit is contained in:
trivialkettle 2024-06-19 14:45:08 +02:00
parent 50159c0e19
commit 07ba67ce41
3 changed files with 4 additions and 9 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname="chirpstack" <<-EOSQL
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname="$POSTGRES_DB" <<-EOSQL
create extension pg_trgm;
create extension hstore;
EOSQL

View File

@ -1,7 +0,0 @@
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
create role chirpstack with login password 'chirpstack';
create database chirpstack with owner chirpstack;
EOSQL

View File

@ -60,7 +60,9 @@ services:
- ./configuration/postgresql/initdb:/docker-entrypoint-initdb.d
- postgresqldata:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=root
- POSTGRES_USER=chirpstack
- POSTGRES_PASSWORD=chirpstack
- POSTGRES_DB=chirpstack
redis:
image: redis:7-alpine