Merge pull request #8 from xcompass/configurable-params
Allow db host, name user and password to be configurable
This commit is contained in:
commit
6918117793
@ -23,7 +23,7 @@
|
||||
},
|
||||
"SqlSettings": {
|
||||
"DriverName": "postgres",
|
||||
"DataSource": "postgres://mmuser:mmuser_password@db:DB_PORT/mattermost?sslmode=disable&connect_timeout=10",
|
||||
"DataSource": "postgres://MM_USERNAME:MM_PASSWORD@DB_HOST:DB_PORT/MM_DBNAME?sslmode=disable&connect_timeout=10",
|
||||
"DataSourceReplicas": [],
|
||||
"MaxIdleConns": 10,
|
||||
"MaxOpenConns": 10,
|
||||
|
@ -1,17 +1,26 @@
|
||||
#!/bin/bash
|
||||
config=/mattermost/config/config.json
|
||||
DB_HOST=${DB_HOST:-db}
|
||||
DB_PORT_5432_TCP_PORT=${DB_PORT_5432_TCP_PORT:-5432}
|
||||
MM_USERNAME=${MM_USERNAME:-mmuser}
|
||||
MM_PASSWORD=${MM_PASSWORD:-mmuser_password}
|
||||
MM_DBNAME=${MM_DBNAME:-mattermost}
|
||||
echo -ne "Configure database connection..."
|
||||
if [ ! -f $config ]
|
||||
then
|
||||
cp /config.template.json $config
|
||||
sed -Ei "s/DB_HOST/$DB_HOST/" $config
|
||||
sed -Ei "s/DB_PORT/$DB_PORT_5432_TCP_PORT/" $config
|
||||
sed -Ei "s/MM_USERNAME/$MM_USERNAME/" $config
|
||||
sed -Ei "s/MM_PASSWORD/$MM_PASSWORD/" $config
|
||||
sed -Ei "s/MM_DBNAME/$MM_DBNAME/" $config
|
||||
echo OK
|
||||
else
|
||||
echo SKIP
|
||||
fi
|
||||
|
||||
echo "Wait until database is ready..."
|
||||
until nc -z db $DB_PORT_5432_TCP_PORT
|
||||
until nc -z $DB_HOST $DB_PORT_5432_TCP_PORT
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
|
@ -1,6 +1,12 @@
|
||||
export PGUSER=postgres
|
||||
psql <<- EOSQL
|
||||
CREATE DATABASE mattermost;
|
||||
CREATE USER mmuser WITH PASSWORD 'mmuser_password';
|
||||
GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
MM_USERNAME=${MM_USERNAME:-mmuser}
|
||||
MM_PASSWORD=${MM_PASSWORD:-mmuser_password}
|
||||
MM_DBNAME=${MM_DBNAME:-mattermost}
|
||||
|
||||
psql -v ON_ERROR_STOP=1 --username "postgres" <<- EOSQL
|
||||
CREATE DATABASE $MM_DBNAME;
|
||||
CREATE USER $MM_USERNAME WITH PASSWORD '$MM_PASSWORD';
|
||||
GRANT ALL PRIVILEGES ON DATABASE $MM_DBNAME to $MM_USERNAME;
|
||||
EOSQL
|
||||
|
Reference in New Issue
Block a user