Hi all,
I am attempting to deploy a Spring Boot application via a Blueprint. The app requires a connection to a database. This works fine on local. But if I define a Blueprint with the database and web service, the deployment fails with:
Caused by: java.net.UnknownHostException: <internal url>
Curiously, if I manually update the hostname to the external one, the service is able to connect. This would be fine, but it does not seem that RENDER_EXTERNAL_HOSTNAME
is available for databases.
Any guidance on how to resolve/workaround this issue is greatly appreciated.
Config
My render.yaml
looks a bit like this:
services:
- type: web
name: my-app
env: docker
envVars:
- key: DATABASE_HOST
fromDatabase:
name: db
property: host
- key: DATABASE_SCHEMA
fromDatabase:
name: db
property: database
- key: DATABASE_USER
fromDatabase:
name: db
property: user
- key: DATABASE_PASSWORD
fromDatabase:
name: db
property: password
databases:
- name: db
application.yml
like this:
spring:
datasource:
url: jdbc:postgresql://${DATABASE_HOST:localhost}:5432/${DATABASE_SCHEMA:postgres}
username: ${DATABASE_USERNAME:postgres}
password: ${DATABASE_PASSWORD:postgres}
driver-class-name: org.postgresql.Driver
And Dockerfile
for the service looks like this:
FROM maven:3.8.6-eclipse-temurin-19-alpine AS maven
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN mvn package -Dmaven.test.skip
FROM eclipse-temurin:19-jdk-alpine
ARG JAR_FILE=my-app.jar
WORKDIR /opt/app
COPY --from=maven /usr/src/app/target/*.jar /opt/app/${JAR_FILE}
ENTRYPOINT ["java","-jar","my-app.jar"]