Dockerized Spring Boot app can't get JDBC connection string on Heroku - spring-boot

I'm trying to run the Dockerized Spring Boot application on Heroku. I use dockerfile-maven and plugin to create the app I use this commands
heroku apps:create my-app-name --buildpack heroku/java
heroku addons:create heroku-postgresql:hobby-dev --app my-app-name
Notice that I'm using buildpack here.
In application.properties I have such lines
spring.datasource.url=${JDBC_DATABASE_URL:some default jdbc connection string}
spring.datasource.username=${JDBC_DATABASE_USERNAME}
spring.datasource.password=${JDBC_DATABASE_PASSWORD}
How I understand if I set the heroku/java buildpack for the app the environment variables JDBC_DATABASE_URL should be created but in my case, I see the default connection string in logs. That's mean that JDBC_DATABASE_URL is not set or not available. Why that's could happen?
Worth to mention that DATABASE_URL environment variable is available in the application.

Related

Heroku - environment variable for Srping Boot DB connect

I have an app on Spring Boot that running in two environments, local and heroku:
Local - connect to DB is configured by app.properties.
Heroku - app is working w\o app.properties, using one environment variable:
heroku config -a zed-social-network
=== zed-social-network Config Vars
CLEARDB_DATABASE_URL: mysql://{login}:{pass}#host.com/heroku?reconnect=true&useUnicode=true&characterEncoding=UTF-8
Question: how I can configure DB connect in Spring on local machine in same style, with one env variable?
I would use a command line argument:
mvn spring-boot:run -Drun.arguments=--customArgument=custom
so in your case
mvn spring-boot:run -Drun.arguments=--CLEARDB_DATABASE_URL=your_url
--
Alternatively, you could add the url to system variables and then reference it in application.properties like so:
spring.datasource.url=${NAME_OF_THE_SYSTEM_VARIABLE}

How to get Redis Enterprise Cloud URL on Heroku?

I installed Redis Enterprise Cloud on my dyno on Heroku for the first time and didn't find any config in settings as described in the docs
Once Redise Cloud has been added, you will notice a REDISCLOUD_URL config vars in your heroku config containing the username, password, hostname and port of your first Redis Cloud database.
How can I get the REDISCLOUD_URL config after it's installing this addon?
Check the getting started doc:
https://devcenter.heroku.com/articles/rediscloud#getting-started
$ heroku config:get REDISCLOUD_URL

Heroku addons:create --fork doesn't migrate redis data

I have an app hosted on Heroku and I am trying to migrate from Heroku Redis to Redis Cloud.
According to this documentation, I can easily migrate the data from my current Heroku Redis to a new Redis Cloud by using --fork flag.
https://devcenter.heroku.com/articles/rediscloud#migrating-from-an-existing-redis-server-to-redis-cloud
However, when I ran the command, it did create a new Redis Cloud instance but the instance doesn't have the data from my Heroku Redis instance.
This is the command that I used to create the instance
heroku addons:create rediscloud:100 --fork=`heroku config:get REDIS_URL -a app-name` -a app-name
Is the --fork flag only works for databases ?
Correct, fork will make a copy of the application, it's addons and data contained in Heroku Postgres.

Heroku Kafka certificates

According to the documentation, Heroku passes KAFKA_TRUSTED_CERT, KAFKA_CLIENT_CERT and KAFKA_CLIENT_CERT_KEY directly into my heroku applications. In consequence, only applications running on heroku can access Heroku Kafka? I would like to access it directly from my home workstation but i dont know how to get the ENVs
You can run either heroku config --app your_application_name to get all variables, or run heroku config:get KAFKA_TRUSTED_CERT --app your_application_name to just get one specific variable.
You can also login to Heroku dashboard and find all variables there in "Settings" section of your app.

How to deploy meanjs to heroku

I have tried deploying my meanjs on heroku.
I forked this https://github.com/meanjs/mean
1.) Login to heroku
2.) Deploy and connect github repositor
enabled automatic deploy CI
Click on Manual Deploy
On the build log it says "Bulid succeded"
My question is.
Why am I getting this application error?
When all I did was forked the repository and deployed it on heroku?
https://serkolgame.herokuapp.com/
Did you add a mongoDB to your app? Without it, the startup process is likely to fail.
Here are some options:
If you are using the default dev environment - then just add the mongodb connection string in development.js and restart the server
If you are using the prod environment - then you can use environment variables uri: process.env.MONGOHQ_URL or process.env.MONGOLAB_URI
This is assuming you have a mongoDB sandbox setup somewhere, if you don't, you'll first need a mongodb sandbox (get one from Heroku, Compose.io, or MongoLab).

Resources