Skip to content

Commit

Permalink
Update Dockerfile and config for AWS Secrets Manager integration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Gcolon021 committed Aug 26, 2024
1 parent db2902e commit 338f1c3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
11 changes: 10 additions & 1 deletion dictionaryweights/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
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:-}
5 changes: 5 additions & 0 deletions dictionaryweights/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws.secretsmanager</groupId>
<artifactId>aws-secretsmanager-jdbc</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 338f1c3

Please sign in to comment.