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
postgres
user 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.sh
and edit the password in theCREATE USER
query.... 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 +x
if 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.yml
and add theSPRING_DATASOURCE_PASSWORD
environment variable.data-service: ... environment: - SPRING_DATASOURCE_PASSWORD # Not specifying a value allow to transmit environment variable to the container.
-
Edit the
.env
file located indocker-compose.yml
parent folder and add an environment variableSPRING_DATASOURCE_PASSWORD
with the password you have chosen.Note:Note that you can also add the environment variable to the host machine.
-