{"id":6429,"date":"2018-03-11T22:20:09","date_gmt":"2018-03-12T02:20:09","guid":{"rendered":"https:\/\/www.jitendrazaa.com\/blog\/?p=6429"},"modified":"2018-03-11T22:23:44","modified_gmt":"2018-03-12T02:23:44","slug":"access-heroku-postgresql-database-locally-using-docker","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/heroku\/access-heroku-postgresql-database-locally-using-docker\/","title":{"rendered":"Access Heroku PostgreSQL Database Locally using Docker"},"content":{"rendered":"<p style=\"text-align: justify;\"><a href=\"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/heroku\/\">Heroku<\/a> is a <strong>Platform as a Service (PaaS)<\/strong> provided by Salesforce and one of my favorite place to jump and spin off any third party application, which can work seamlessly with Salesforce.\u00a0 <strong>Heroku<\/strong> also provides free <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/postgresql\/\"><strong>PostgreSQL<\/strong><\/a>\u00a0database which can be used by your application.<\/p>\n<p style=\"text-align: justify;\">Sometimes you may be in need to use this cloud based free\u00a0<strong>PostgreSQL\u00a0<\/strong>database offered by Heroku in third party application or your local Server.<\/p>\n<p style=\"text-align: justify;\">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.\u00a0Complete source of this blog post can be found on <a href=\"https:\/\/github.com\/JitendraZaa\/heroku-postgres-local-php\">my Github repository<\/a>.<\/p>\n<p style=\"text-align: justify;\">One important point to note here, local server must support <strong>SSL<\/strong> i.e. https. I have written some posts in past to show how SSL can be enabled in <a href=\"https:\/\/www.jitendrazaa.com\/blog\/java\/simple-guide-to-setup-ssl-in-tomcat\/\">tomcat server<\/a> or <a href=\"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/use-lightning-components-on-external-websites-lightning-out\/\">nodejs<\/a>. This time I wanted to check how it can be done in\u00a0<strong>Docker.<\/strong><\/p>\n<p style=\"text-align: justify;\">I always use\u00a0<strong>Docker\u00a0<\/strong>if I need to use <a href=\"https:\/\/www.jitendrazaa.com\/blog\/tag\/jenkins\/\">Jenkins<\/a> or any other server. Instead of maintaining all servers individually, it is easy and convenient to use container like\u00a0<strong>docker<\/strong> and control servers or applications from there.<\/p>\n<p style=\"text-align: justify;\">First step, of course is to install docker and run it. Next, create a Heroku application and enable\u00a0<strong>PostgreSQL\u00a0<\/strong>add on. After that, clone <a href=\"https:\/\/github.com\/JitendraZaa\/heroku-postgres-local-php\">this Git repository<\/a>.<!--more--><\/p>\n<p style=\"text-align: justify;\">Copy the Database_URL from config variable setting of Heroku application and change below index.php file, line 38.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/JitendraZaa\/90d03a3536db9eeb45268f6b4b659fa5.js\"><\/script><\/p>\n<p>Its time to run below two commands<\/p>\n<pre>docker-compose build\r\ndocker-compose up<\/pre>\n<p style=\"text-align: justify;\">SSL enabled localhost is accessible at <a href=\"https:\/\/localhost\">https:\/\/localhost<\/a> now where we can perform create and read operations on\u00a0<strong>PostgreSQL\u00a0<\/strong>database residing in Heroku.<\/p>\n<p style=\"text-align: justify;\">Complete source of this blog post can be found on <a href=\"https:\/\/github.com\/JitendraZaa\/heroku-postgres-local-php\">my Github repository<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to use Heroku Postgres Database from any third party application or local server<\/p>\n","protected":false},"author":1,"featured_media":6432,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[112],"tags":[439,342,155,276],"class_list":["post-6429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-heroku","tag-docker","tag-heroku","tag-php","tag-postgresql"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2018\/03\/Heroku-Postgres-from-local-PHP-Server.gif?fit=594%2C674&ssl=1","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":4047,"url":"https:\/\/www.jitendrazaa.com\/blog\/webtech\/how-to-use-postgresql-in-nodejs\/","url_meta":{"origin":6429,"position":0},"title":"How to use PostgreSQL in Nodejs","author":"Jitendra","date":"November 17, 2014","format":false,"excerpt":"I have written many articles on Node.js and AngularJs. In this article, I will demonstrate how to use PostgreSQL with Node.js and deploy on Heroku. I think you already smelled that this is one of starting article which will finally merged with Salesforce to create some cool application. Assuming you\u2026","rel":"","context":"In &quot;Node.js&quot;","block_context":{"text":"Node.js","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/others\/node-js\/"},"img":{"alt_text":"PostgreSQL in Node.js","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/11\/PostgreSQL-in-Node.js.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/11\/PostgreSQL-in-Node.js.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/11\/PostgreSQL-in-Node.js.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3231,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/creating-first-application-in-heroku-using-eclipse\/","url_meta":{"origin":6429,"position":1},"title":"Creating First Application in Heroku using Eclipse","author":"Jitendra","date":"March 3, 2013","format":false,"excerpt":"Hello Readers, in this article we will see step by step procedure to deploy your first (Hello World) program in Heroku. There are two ways, first going through series of Commands of \"Heroku\" and \"GIT\" and other simple and smart way is to use Eclipse Capability with Heroku. To make\u2026","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"Setting up Credentials for Heroku in Eclipse","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/03\/Setting-up-Credentials-for-Heroku-in-Eclipse.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/03\/Setting-up-Credentials-for-Heroku-in-Eclipse.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2013\/03\/Setting-up-Credentials-for-Heroku-in-Eclipse.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3937,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/heroku\/create-node-js-application-using-eclipse-and-deploy-to-heroku-video-tutorial\/","url_meta":{"origin":6429,"position":2},"title":"Create Node.js Application using Eclipse and deploy to Heroku &#8211; Video Tutorial","author":"Jitendra","date":"July 27, 2014","format":false,"excerpt":"In Below video, I have explained how to create basic Node.js application in Eclipse with help of Egit and Heroku plugin and deploy to Heroku. Please read below two articles, to get familiar of Plugins and how to setup : Salesforce + Git + Eclipse + EGIT = Better and\u2026","rel":"","context":"In &quot;Heroku&quot;","block_context":{"text":"Heroku","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/heroku\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3951,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/creating-salesforce-query-builder-in-node-js-and-angularjs-using-salesforce-rest-api-and-oauth2\/","url_meta":{"origin":6429,"position":3},"title":"Creating Salesforce Query Builder in Node.js and AngularJs using Salesforce REST API and OAuth2 with Heroku Button","author":"Jitendra","date":"August 18, 2014","format":false,"excerpt":"In this post, we will be creating a\u00a0Salesforce Query (SOQL) Builder.\u00a0It uses Google's Angularjs MVC Javascript library and REST API provided by Salesforce. For Authentication, it uses OAuth2. Node.js is used as a primary language and hosted on Heroku. If you want to directly deploy to your Heroku Account, You\u2026","rel":"","context":"In &quot;HTML&quot;","block_context":{"text":"HTML","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/webtech\/web\/"},"img":{"alt_text":"SOQL Builder Using Node.js AngularJs Salesforce REST API on Heroku","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/08\/SOQL-Builder-Using-Node.js-AngularJs-Salesforce-REST-API-on-Heroku-1024x504.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/08\/SOQL-Builder-Using-Node.js-AngularJs-Salesforce-REST-API-on-Heroku-1024x504.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/08\/SOQL-Builder-Using-Node.js-AngularJs-Salesforce-REST-API-on-Heroku-1024x504.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3930,"url":"https:\/\/www.jitendrazaa.com\/blog\/others\/tips\/resolve-error-eclipse-ssh-key-is-not-matching-the-ssh-keys-that-is-associated-with-your-heroku-account\/","url_meta":{"origin":6429,"position":4},"title":"Resolve Error : Eclipse SSH key is not matching the SSH key(s) that is associated with your Heroku account","author":"Jitendra","date":"July 27, 2014","format":false,"excerpt":"We have seen that how to create First Heroku application using Eclipse.\u00a0However it is possible that after following all steps properly in above article you may receive error saying the Eclipse SSH key is not matching the SSH key(s) that is associated with your Heroku account. To fix this error,\u2026","rel":"","context":"In &quot;Tech Tips&quot;","block_context":{"text":"Tech Tips","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/others\/tips\/"},"img":{"alt_text":"Clone Git from Heroku","src":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/07\/Clone-Git-from-Heroku.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/07\/Clone-Git-from-Heroku.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.jitendrazaa.com\/blog\/wp-content\/uploads\/2014\/07\/Clone-Git-from-Heroku.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":5539,"url":"https:\/\/www.jitendrazaa.com\/blog\/salesforce\/lightning-component-code-review-using-cli-video\/","url_meta":{"origin":6429,"position":5},"title":"Lightning component code review using CLI &#8211; Video","author":"Jitendra","date":"June 15, 2016","format":false,"excerpt":"Video tutorial explaining how we can use Lightning CLI to identify possible issues and enhancements needed for Lightning Component and enabling it for Locker Service","rel":"","context":"In &quot;Salesforce&quot;","block_context":{"text":"Salesforce","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/salesforce\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/img.youtube.com\/vi\/f1Zn61WYMZM\/0.jpg?resize=350%2C200","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=6429"}],"version-history":[{"count":4,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6429\/revisions"}],"predecessor-version":[{"id":6435,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/6429\/revisions\/6435"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media\/6432"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=6429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=6429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=6429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}