Configuring Postgres 'data_server' Credentials
The Postgres data_server credentials have to be changed with an SQL query directly done in the PostgreSQL instance connected with postgres-r00t-us3rn4m3 admin account.
To Configure Postgres 'data_server' Credentials
-
With the tools of your choice, connect to the database with the
postgresuser at the JDBC URL:jdbc:postgresql://localhost:5432/postgres. -
Run the following SQL query:
ALTER ROLE data_server WITH PASSWORD ...NEW_PASSWORD...;
-
Only on the target machine, i.e. the machine that hosts the deployments script and the Docker file, open the script
deployment/docker/infra/postgres/start/10-create_user.shand edit the password in theCREATE USERquery.... echo "Creating database role: data_server" psql --username "$POSTGRES_USER" <<-EOSQL CREATE USER data_server WITH CREATEDB PASSWORD 'NEW_PASSWORD'; EOSQL
This ensures the change survives to volume removing.
Note:Note that the script files must be executable. Run
chmod +xif needed. -
Change the password configuration in the microservices that need to connect to Postgres through this user (in this particular case it is
data-service).-
Edit
deployment/docker/infra/docker-compose.ymland add theSPRING_DATASOURCE_PASSWORDenvironment variable.data-service: ... environment: - SPRING_DATASOURCE_PASSWORD # Not specifying a value allow to transmit environment variable to the container. -
Edit the
.envfile located indocker-compose.ymlparent folder and add an environment variableSPRING_DATASOURCE_PASSWORDwith the password you have chosen.Note:Note that you can also add the environment variable to the host machine.
-