Below is my blog post on setting up a hello world app on Heroku that is powered by a database (e.g Client requests a page, the page reads a database and return hello world).
I found IBM/Cloudant would cost multiple thousands a month to run a good NoSQL database backend, I moved to a self-managed server on Digital Ocean in Singapore but the distance of the server killed latency and maximum throughput in Australia. I moved to a dedicated AWS EC2 instance with a Mongo DB cluster on AWS in Australia and it was great but pricey. A self-managed server (on Digital Ocean or Vultr) allows you to install whatever you want (e.g PHP, MySQL, MongoDB, Redis, SSL Certificate, Mail or WordPress) and configure what you want (but at what cost?).
Heroku say: “Get straight to building apps – Setting up, operating and maintaining your own platform is not where the race is won. Avoid the risk and complexity, and dedicate your energy to what really matters: building great apps.”.
Having setup serves on IBM Cloudant, Digital Ocean, AWS and Vultr (and even managing with RunCoud and Webmin) and not focusing on a self-managed server-issues like security, backup, security audits, upgrading PHP, updating ssl, setting up distributed mysql, updating https certificates etc sounds like the holy grail.
Let’s put that to the tets and build a Hello World App.
Heroku have a page here about what they offer.
Sign up for Free: https://signup.heroku.com
Programming Languages (Ruby, PHP, Python, NodeJS, Java, Cloujure, Scala, Go etc). I so wanted to select “I’m not a developer” but I won’t. I selected NodeJS.
Next: Verify your email, enter a password and you’ll find yourself here.
Now we can create an app?
Ok, let’s skim the NodeJS help before we start: https://devcenter.heroku.com/articles/getting-started-with-nodejs#set-up
Let’s download the Command Line tools
Installing Heroku CLI on OSX was uneventful
I clicked the “I have installed the Heroku CLI” button.
Heroku wanted me to clone a repo but I logged in to Heroku the Heroku CLI and created a local Heroku folder first (in my local Terminal).
I checked the Heroku Version
I checked Heroku Help
heroku --help Usage: heroku COMMAND Help topics, type heroku help TOPIC for more details: access manage user access to apps addons tools and services for developing, extending, and operating your app apps manage apps auth heroku authentication authorizations OAuth authorizations buildpacks manage the buildpacks for an app certs a topic for the ssl plugin ci run an application test suite on Heroku clients OAuth clients on the platform config manage app config vars container Use containers to build and deploy Heroku apps domains manage the domains for an app drains list all log drains features manage optional features git manage local git repository for app keys manage ssh keys labs experimental features local run heroku app locally logs display recent log output maintenance manage maintenance mode for an app members manage organization members notifications display notifications orgs manage organizations pg manage postgresql databases pipelines manage collections of apps in pipelines plugins manage plugins ps manage dynos (dynos, workers) redis manage heroku redis instances regions list available regions releases manage app releases run run a one-off process inside a Heroku dyno sessions OAuth sessions spaces manage heroku private spaces status status of the Heroku platform teams manage teams update update CLI webhooks setup HTTP notifications of app activity
I ran the advised commands
At this point, I followed the steps at https://devcenter.heroku.com/articles/getting-started-with-nodejs#deploy-the-app
The website is up
Where is this app located
Traceroute times out but appears to be in the eastern United States (AWS).
Q1) Can I change to Sydney Australia?
Waiting for an answer from Twitter.
Virginia is a long way away.
It’s all good apart from on weak cipher (“TLS_RSA_WITH_3DES_EDE_CBC_SHA (0xa) WEAK (112)“).
A shodan scan of the IP reveals an open port 80 and 443 (as expected, nothing out of the ordinary)
I ran this to push the app.
I ran this to ensure the app was running
I ran this to open the app
This opened the apps URL in a browser.
A nice help page was pushed to my app.
I changed the contents of “node-js-getting-started/views/pages/index.ejs” and repushed.
It reported “Everything up-to-date“???
I tried to force a push (just in-case something on the server was changed)
Ok, let’s pull and see what’s new?
I edited “./index.js” and made the entry point “pages/index2.ejs” and tried to push and no luck.
I tried running push under sudo too (no luck)
Googling revealed I can go to https://dashboard.heroku.com/apps/YOUR-APP/deploy/heroku-gi and see what the issue is.
I logged into the app and could not find how to delete or edit it?
At this point, I would have just ssh’ed in and restarted the node process in pm2 or node on my own self-managed server and edited remote files locally in sublime on my local machine.
Personally, I like to know where files live and not delve into another designers management interface.
Linking to your own Domain on Heroku
It looks like I can use custom domains via Namecheap to link a domain to a heroku app.
Or you can setup a domain sub domain to point to a heroku app with a DNS C Name record.
App Cost on Heroku
Donate and make this blog better
Ask a question or recommend an article
[contact-form-7 id=”30″ title=”Ask a Question”]
v1.4 added custom domain, database, CNAME info