From 338f1c352010a87cae981c3e1a5ea5352eeda861 Mon Sep 17 00:00:00 2001 From: GeorgeC Date: Mon, 26 Aug 2024 12:07:20 -0400 Subject: [PATCH] Update Dockerfile and config for AWS Secrets Manager integration Added environment variables and updated entrypoint in Dockerfile. Modified pom.xml to include AWS Secrets Manager JDBC dependency. Updated application properties to use AWS Secrets Manager for database credentials. --- dictionaryweights/Dockerfile | 11 ++++++++++- dictionaryweights/pom.xml | 5 +++++ .../src/main/resources/application-bdc.properties | 8 ++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dictionaryweights/Dockerfile b/dictionaryweights/Dockerfile index 5bab457..cc88383 100644 --- a/dictionaryweights/Dockerfile +++ b/dictionaryweights/Dockerfile @@ -13,4 +13,13 @@ FROM amazoncorretto:22-alpine # Copy jar and access token from maven build COPY --from=build target/dictionaryweights-*.jar /dictionaryweights.jar -ENTRYPOINT java -jar /dictionaryweights.jar \ No newline at end of file +ARG DATASOURCE_URL +ARG DATASOURCE_USERNAME +ARG SPRING_PROFILE + +# If a --env-file is passed in, you can override these values +ENV DATASOURCE_URL=${DATASOURCE_URL} +ENV DATASOURCE_USERNAME=${DATASOURCE_USERNAME} +ENV SPRING_PROFILE=${SPRING_PROFILE} + +ENTRYPOINT java -jar /dictionaryweights.jar --spring.profiles.active=${SPRING_PROFILE:-} \ No newline at end of file diff --git a/dictionaryweights/pom.xml b/dictionaryweights/pom.xml index 9bc2280..5294e33 100644 --- a/dictionaryweights/pom.xml +++ b/dictionaryweights/pom.xml @@ -61,6 +61,11 @@ postgresql test + + com.amazonaws.secretsmanager + aws-secretsmanager-jdbc + 2.0.2 + diff --git a/dictionaryweights/src/main/resources/application-bdc.properties b/dictionaryweights/src/main/resources/application-bdc.properties index c0f75a9..5ecc746 100644 --- a/dictionaryweights/src/main/resources/application-bdc.properties +++ b/dictionaryweights/src/main/resources/application-bdc.properties @@ -1,9 +1,9 @@ spring.application.name=dictionaryweights spring.main.web-application-type=none -spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST}:5432/dict?currentSchema=dict -spring.datasource.username=${POSTGRES_USER} -spring.datasource.password=${POSTGRES_PASSWORD} -spring.datasource.driver-class-name=org.postgresql.Driver +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +spring.datasource.driver-class-name=com.amazonaws.secretsmanager.sql.AWSSecretsManagerPostgreSQLDriver +spring.datasource.url=jdbc-secretsmanager:postgresql://${DATASOURCE_URL}/dict?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&autoReconnectForPools=true +spring.datasource.username=${DATASOURCE_USERNAME} weights.filename=/weights.csv \ No newline at end of file