Heroku is a Platform as a Service (PaaS) provided by Salesforce and one of my favorite place to jump and spin off any third party application, which can work seamlessly with Salesforce. Heroku also provides free PostgreSQL database which can be used by your application.
Sometimes you may be in need to use this cloud based free PostgreSQL database offered by Heroku in third party application or your local Server.
I was able to do it very quickly and easily and want to make sure would not forget in future, so here is the post. Complete source of this blog post can be found on my Github repository.
One important point to note here, local server must support SSL i.e. https. I have written some posts in past to show how SSL can be enabled in tomcat server or nodejs. This time I wanted to check how it can be done in Docker.
I always use Docker if I need to use Jenkins or any other server. Instead of maintaining all servers individually, it is easy and convenient to use container like docker and control servers or applications from there.
First step, of course is to install docker and run it. Next, create a Heroku application and enable PostgreSQL add on. After that, clone this Git repository.
Copy the Database_URL from config variable setting of Heroku application and change below index.php file, line 38.
Its time to run below two commands
docker-compose build docker-compose up
SSL enabled localhost is accessible at https://localhost now where we can perform create and read operations on PostgreSQL database residing in Heroku.
Complete source of this blog post can be found on my Github repository.
Leave a Reply