Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How dockerize Spring Boot app if Postgres db is going to be AWS RDS?

    version: "3.7"
services:
  api_service:
    build: .
    restart: always
    ports:
      - 8080:8080
    depends_on:
      - postgres_db
    links:
      - postgres_db:database
  postgres_db:
    image: "postgres:11.4"
    restart: always
    ports:
      - 5435:5432
    environment:
      POSTGRES_DB: testDb
      POSTGRES_PASSWORD: admin

this is my yaml

and I got properties

spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://database:5432/testDb
spring.datasource.username=postgres
spring.datasource.password=admin

if my postgres is rds then do I need to compose them or I just can go with dockerfile for jar only and not yaml file?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can create environment variables for the RDS address, RDS username, RDS password and RDS port. Pass it to the Dockerfile to the api_service. Your api_service should know to assemble Postgres connection string based on the environment variables. Please check – Spring Profiles in connection String

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading