Heroku Postgres from local PHP Server

Access Heroku PostgreSQL Database Locally using Docker

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.

Posted

in

by


Related Posts

Comments

One response to “Access Heroku PostgreSQL Database Locally using Docker”

  1. coobs Avatar
    coobs

    I get this error message: E: Package ‘mysql-client-5.5’ has no installation candidate
    E: Package ‘libpng12-dev’ has no installation candidate
    E: Package ‘libpng12-dev’ has no installation candidate. I know that libpng12-dev has been retired and that I should use ibpng12 but where can I find that package.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading