B.5 Create a Docker Secret for Oracle Database Credentials

MicroTx supports using Oracle Database as a persistent store to keep track of the transaction information. You must provide the Oracle Database credentials in the YAML file. MicroTx uses the credentials to establish a connection to the database after the service is installed.

Skip this step if you are not using Oracle Database to store the transaction details of MicroTx.

If you are using an Autonomous Database instance, ensure that you have downloaded the wallet and noted the connection string before you begin with the following steps. See Get Autonomous Database Client Credentials.
To create a Docker secret to provide the Oracle Database login details:
  1. Enter the Oracle Database credentials in the following format in any text editor, such as Notepad. Replace the sample values with values that are specific to your environment.
    {
      "password": "enter_your_Database_password",
      "username": "enter_the_username_to_access_the_Database"
    }
  2. Save the file with a TXT format. For example, database_secret.txt. Note down the path and name of this file as you'll need to provide it in the next step.
  3. Create a Docker secret with the Oracle Database login details.

    Command syntax

    docker secret create <name_of_the_secret> </path_to_text_file>/<name_of_text_file

    Sample command

    The following commands creates a Docker secret with the name STORAGE_DB_CREDENTIAL.

    docker secret create STORAGE_DB_CREDENTIAL /database_secret.txt
  4. Run the following command to verify that the secret has been created.
    docker secret ls

    Sample response

    
    ID         NAME                    DRIVER     CREATED          UPDATED
    ovn1x...   STORAGE_DB_CREDENTIAL              11 seconds ago   11 seconds ago

    To improve readability, the sample value in the response is truncated with .... When you run this command in your environment, you'll see the complete value.

    Note down the name of the Docker secret that you have created. You will need to provide this name later.

  5. Open the tmm-stack-compose.yaml file in any text editor. This file is located in the installation_directory/otmm-<version>/samples/docker folder.
  6. Update the otmm-tcs service and secrets sections with the details of the Docker secret that you have created. The following code snippet shows sample values.
    secrets:
      STORAGE_DB_CREDENTIAL:
        external: true
    services:
      otmm-tcs:
        image: "127.0.0.1:5000/tmm"
        ports:
          - "9000:9000"
        deploy:
          replicas: 1
        configs:
          - source: my_tcs_config
            target: /tcs.yaml
        # Create an environment variable that points to the Docker secret that you have created.
        entrypoint: ['/bin/sh', '-c', 'export STORAGE_DB_CREDENTIAL=$$(cat /run/secrets/STORAGE_DB_CREDENTIAL); /app/tcs' ]
        environment:
          - CONFIG_FILE=/tcs.yaml
        secrets:
          - STORAGE_DB_CREDENTIAL

    Where, STORAGE_DB_CREDENTIAL is the name of the Docker secret that you have created. Add an entrypoint to create an environment variable that points to the Docker secret that you have created. The name of the environment variable and the Docker secret are the same in the sample code snippet.

  7. Enter the database connection string. Only if you are using an Autonomous Database instance, you must also specify the wallet details in the volumes parameter. For details about the format of the connection string for Autonomous Database instance, see Get Autonomous Database Client Credentials.
    secrets:
      STORAGE_DB_CREDENTIAL:
        external: true
    services:
      otmm-tcs:
        image: "127.0.0.1:5000/tmm"
        ports:
          - "9000:9000"
        deploy:
          replicas: 1
        configs:
          - source: my_tcs_config
            target: /tcs.yaml
        volumes:
          - /<PATH_TO_DOWNLOADED_WALLET>/<WALLET_FOLDER_NAME>:/app/Wallet
        entrypoint: ['/bin/sh', '-c', 'export STORAGE_DB_CREDENTIAL=$$(cat /run/secrets/STORAGE_DB_CREDENTIAL); /app/tcs' ]
        environment:
          - CONFIG_FILE=/tcs.yaml
        secrets:
          - STORAGE_DB_CREDENTIAL
    storage:
        type: db
        #Allowed types - etcd/db/memory
        db:
          connectionString: tcps://adb.us-ashburn-1.oraclecloud.com:1522/bfeldfxbtjvtddi_brijeshadw1_medium.adb.oraclecloud.com?retry_count=20&retry_delay=3&wallet_location=/app/Wallet