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

  1. With the tools of your choice, connect to the database with the postgres user at the JDBC URL: jdbc:postgresql://localhost:5432/postgres.

  2. Run the following SQL query:

    ALTER ROLE data_server WITH PASSWORD ...NEW_PASSWORD...;
  3. 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 the CREATE 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.

  4. Change the password configuration in the microservices that need to connect to Postgres through this user (in this particular case it is data-service).

    1. Edit deployment/docker/infra/docker-compose.yml and add the SPRING_DATASOURCE_PASSWORD environment variable.

      data-service:
           ...
           environment:
           - SPRING_DATASOURCE_PASSWORD # Not specifying a value allow to transmit environment variable to the container.
    2. Edit the .env file located in docker-compose.yml parent folder and add an environment variable SPRING_DATASOURCE_PASSWORD with the password you have chosen.

      Note:

      Note that you can also add the environment variable to the host machine.