Issue
If you check the commit for the sample aws-apprunner-terraform code (which uses petclinic) you will find that they include in their dockerfile the following:
ENTRYPOINT env spring.datasource.password=$(aws ssm get-parameter --name /database/password --with-decrypt --region $AWS_REGION | grep Value | cut -d '"' -f4) java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
Essentially it is setting the spring.datasource.password
environment variable dynamically at runtime to retrieve a value from the AWS SSM. This is all fine when using a Dockerfile.
But when I build my application using Spring Boot's in-built bootBuildImage
task (I use gradle) I'm not sure how to achieve the same effect.
How can I set a environment variable value to be dynamic like is done in the example above when using the build pack provided by Spring Boot?
Solution
You could create a .profile
in the root of your repo with contents like:
export MY_VAR=$(some-dynamic-value)
More info: https://github.com/buildpacks/spec/blob/main/buildpack.md#app-interface
Answered By - codefinger
Answer Checked By - Robin (JavaFixing Admin)