<p>I have a springboot application which uses a postgresql database and a mongoDB database , I have been able to correctly configure them but now when I want to dockerize my application to later deploy it on a Kubernetes cluster, I am completely clueless. Most of the youtube tutorials and articles are on how to dockerize simple springboot applications or springboot applications that use only one database, thus any input on how I can proceed to dockerize my application would be really appreciated!</p>
<p>Edit:
I am following this tutorial -
<a href="https://www.section.io/engineering-education/running-a-multi-container-springboot-postgresql-application-with-docker-compose/" rel="nofollow noreferrer">https://www.section.io/engineering-education/running-a-multi-container-springboot-postgresql-application-with-docker-compose/</a></p>
<p>Here in the docker-compose.yml file-</p>
<pre><code>version: '3.1'
services:
  API:
    image: 'blog-api-docker.jar'
    ports:
      - &quot;8080:8080&quot;
    depends_on:
      PostgreSQL:
        condition: service_healthy
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://PostgreSQL:5432/postgres
      - SPRING_DATASOURCE_USERNAME=postgres
      - SPRING_DATASOURCE_PASSWORD=password
      - SPRING_JPA_HIBERNATE_DDL_AUTO=update

  PostgreSQL:
    image: postgres
    ports:
      - &quot;5432:5432&quot;
    environment:
      - POSTGRES_PASSWORD=password
      - POSTGRES_USER=postgres
      - POSTGRES_DB=postgres
    healthcheck:
      test: [&quot;CMD-SHELL&quot;, &quot;pg_isready -U postgres&quot;]
      interval: 10s
      timeout: 5s
      retries: 5
</code></pre>
<p>Only one postgreSQL datasource is defined ,in my project with a similar postgreSQL datasource as given in the tutorial I am also using a mongoDB database which is running on atlas.
I am also including my application.properties file for your reference-</p>
<pre><code>    spring.ds-psql.datasource.jdbcUrl=jdbc:postgresql://localhost:5432/devicestatspsql
    spring.ds-psql.datasource.username=
    spring.ds-psql.datasource.password=
    
    spring.data.mongodb.users-mongo-atlas.uri=*mongodb database url here*

    spring.jpa.generate-ddl=true
    spring.jpa.show-sql=true
</code></pre>
<p>So I just need to know what changes are required in my docker-compose.yml file to accommodate this mongodb database in the docker image</p>

kratia
<p>You can use the Kubernetes <a href="https://kubernetes.io/docs/concepts/configuration/configmap/" rel="nofollow noreferrer"><strong>Configmap</strong></a> and <a href="https://kubernetes.io/docs/concepts/configuration/secret/" rel="nofollow noreferrer"><strong>Secret</strong></a> as of now to store the configuration of your application.</p>
<p>Configmap and Secret are mostly for storing configurations like database connection strings, usernames, and passwords.</p>
<p>You can create different configuration maps as per requirement for Dev,Stag and Prod then inject the specific to your deployment so the application will get those values from either <code>.env</code> file or from <code>OS environment</code>.</p>
<p>Here's the reference <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">article</a>.</p>
