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).
Last login: Sat Nov 25 18:54:43 on ttys000 192-168-1-200:~ username$ mkdir ~/Desktop/heroku 192-168-1-200:~ username$ cd ~/Desktop/heroku 192-168-1-200:heroku simon$ pwd /Users/username/Desktop/heroku 192-168-1-200:~ username$ heroku login heroku-cli: Updating to 6.14.38-9bfc11a... 12.7 MB/12.7 MB Enter your Heroku credentials: Email: [email protected] Password: *******************************************************
I checked the Heroku Version
heroku --version heroku-cli/6.14.38-9bfc11a (darwin-x64) node-v9.2.0
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
git clone https://github.com/heroku/node-js-getting-started.git cd node-js-getting-started
At this point, I followed the steps at https://devcenter.heroku.com/articles/getting-started-with-nodejs#deploy-the-app
heroku create Creating app... done, ⬢ fathomless-anchorage-##### https://fathomless-anchorage-##removed##.herokuapp.com/ | https://git.heroku.com/fathomless-anchorage-70974.git
The website is up
Where is this app located
traceroute fathomless-anchorage-70974.herokuapp.com traceroute: Warning: fathomless-anchorage-70974.herokuapp.com has multiple addresses; using 22.214.171.124 traceroute to us-east-1-a.route.herokuapp.com (126.96.36.199), 64 hops max, 52 byte packets 1 192-168-1-1 (192.168.1.1) 1.045 ms 1.121 ms 0.727 ms 2 10.20.23.227 (10.20.23.227) 34.415 ms 30.378 ms 26.927 ms 3 syd-gls-har-agr11-be-12 (188.8.131.52) 42.363 ms 42.957 ms 35.670 ms 4 203-221-3-3 (184.108.40.206) 37.517 ms 203-221-3-4 (220.127.116.11) 29.832 ms 203-221-3-67 (18.104.22.168) 29.412 ms 5 10ge4-11.core1.sjc1.he.net (22.214.171.124) 208.270 ms 213.679 ms las-b24-link.telia.net (126.96.36.199) 181.162 ms 6 las-b21-link.telia.net (188.8.131.52) 173.171 ms 100ge1-1.core1.sjc2.he.net (184.108.40.206) 208.705 ms 10ge7-2.core1.sjc2.he.net (220.127.116.11) 212.061 ms 7 dls-b21-link.telia.net (18.104.22.168) 205.615 ms 100ge2-1.core4.fmt2.he.net (22.214.171.124) 204.186 ms dls-b21-link.telia.net (126.96.36.199) 204.317 ms 8 a100us-ic-303626-dls-bb1.c.telia.net (188.8.131.52) 332.192 ms 205.536 ms 100ge11-1.core1.dal1.he.net (184.108.40.206) 241.649 ms 9 220.127.116.11 (18.104.22.168) 209.481 ms 22.214.171.124 (126.96.36.199) 223.887 ms 188.8.131.52 (184.108.40.206) 205.608 ms 10 220.127.116.11 (18.104.22.168) 205.849 ms 22.214.171.124 (126.96.36.199) 274.887 ms 188.8.131.52 (184.108.40.206) 230.285 ms 11 * 220.127.116.11 (18.104.22.168) 232.125 ms * 12 * * 22.214.171.124 (126.96.36.199) 231.710 ms 13 * 188.8.131.52 (184.108.40.206) 239.321 ms * 14 * * * 15 *^C
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.
cd /Users/username/Desktop/heroku/node-js-getting-started git push heroku masterCounting objects: 488, done. Delta compression using up to 8 threads. Compressing objects: 100% (367/367), done. Writing objects: 100% (488/488), 231.76 KiB | 231.76 MiB/s, done. Total 488 (delta 86), reused 488 (delta 86) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected remote: remote: -----> Creating runtime environment remote: remote: NPM_CONFIG_LOGLEVEL=error remote: NPM_CONFIG_PRODUCTION=true remote: NODE_VERBOSE=false remote: NODE_ENV=production remote: NODE_MODULES_CACHE=true remote: remote: -----> Installing binaries remote: engines.node (package.json): 8.9.1 remote: engines.npm (package.json): unspecified (use default) remote: remote: Resolving node version 8.9.1... remote: Downloading and installing node 8.9.1... remote: Using default npm version: 5.5.1 remote: remote: -----> Restoring cache remote: Skipping cache restore (not-found) remote: remote: -----> Building dependencies remote: Installing node modules (package.json) remote: added 49 packages in 1.686s remote: remote: -----> Caching build remote: Clearing previous node cache remote: Saving 2 cacheDirectories (default): remote: - node_modules remote: - bower_components (nothing to cache) remote: remote: -----> Build succeeded! remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> Compressing... remote: Done: 17.7M remote: -----> Launching... remote: Released v3 remote: https://fathomless-anchorage-#####.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/fathomless-anchorage-#####.git * [new branch] master -> master
I ran this to ensure the app was running
heroku ps:scale web=1 Scaling dynos... done, now running web at 1:Free
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.
git push heroku master heroku ps:scale web=1 heroku open
It reported “Everything up-to-date“???
I tried to force a push (just in-case something on the server was changed)
git push --force heroku master Everything up-to-date
Ok, let’s pull and see what’s new?
git pull heroku master From https://git.heroku.com/fathomless-anchorage-##### * branch master -> FETCH_HEAD Already up-to-date.
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