I am trying to connect to the heroku postgres database I provisioned (not a docker image), from a docker app I deployed to heroku. When I push to heroku the image builds fine but when the app starts I get an error. It seems like the JDBC_DATABASE_URL is not being injected into the docker container, but I don't know how to get it to work.
Here is my code:
heroku.yml
build:
docker:
web: Dockerfile
Dockerfile
FROM openjdk:8-jdk-alpine
COPY build/libs/myapp-0.0.1-SNAPSHOT.jar app.jar
CMD ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
application.properties
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url=${JDBC_DATABASE_URL}
spring.datasource.username=${JDBC_DATABASE_USERNAME}
spring.datasource.password=${JDBC_DATABASE_PASSWORD}
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.show-sql=true
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=update
Exception
java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, ${JDBC_DATABASE_URL}
RuntimeException, the var named{JDBC_DATABASE_URL}is called but never created before.