Heroku to Firebase

Serves directly from Google Cloud.

When Google decided to mark all unencrypted website (read: HTTP) as Non-Secure, my blog is going to be marked as well since I don’t have encryption set up. It didn’t bother me back then due to this is just a simple blog that did not accept data from visitor. But when I learned about non-secure website is not going to show up in Google search results, I had to do something - quick.

I wrote back in 2013 about how to hosting your website on Heroku and it really changed me as a developer ever since. I can focus on the development without having to worry about hosting. It just works.

Even with the Free Plan it works for my need. I had all the static assets to serve from Incapsula CDN (Content Delivery Network) first and this pretty much eliminates all the delay of waiting for the dyno to wake up. For media, I hosted it on Cloudinary that has its own CDN. I migrated all my previous projects to Heroku, unsubscribe from previous hosting and been really happy with the progress.

When Honeymoon is over

To implant SSL certificate for HTTPS, I had no option but to sign up for $7/month Hobby Plan. For my basic requirement and not to mention currency exchange in my country (MYR), this is definitely not something I find worth to spend. After all, I didn’t have any plan to attract a lot of traffic or to monetize this blog. It stays a hobby and experimental web app for me to play with.

So I started to look for alternative - one that will work with current development setup. Because my nanoc setup has been heavily customised, there is a risk I could end up having to rebuild everything. And I pretty much would like to avoid that.

Firebase to the rescue

At first I was thinking to just create a Debian droplets on DigitalOcean - aside from it will set me back $5 per month, I can justify the spending since I have so much freedom to expand the capability. But the more I think about it, the more I refrain from doing it.

So I put down three things to help me with the searching for replacement :

1. Mandatory Cloud-based service. Deploy using Git or Terminal. PaaS or BaaS, doesn’t matter as long as its not P.I.T.aaS.

2. Reasonable plan and pricing. Pinch my arm if its free.

3. Fits into my setup without too much fuss.

After a week of searching, the only reasonable replacement to move over from Heroku as cloud hosting for my blog is Firebase.

Just take a look at its key capabilities :

The only downside is Firebase only support a handful of language, and for web hosting it runs as Javascript (Node.js) app. Since my blog is based on Ruby, I had to study how to implant Node without steering too much from current setup. My rack config, has very specific routing and caching mechanism that might not be supported by Firebase’s Node.js. Adding insult to injury, Java isn’t my cup of tea when it comes to programming. But I digress.

Based on nothing but official documentation and hosting behavior guide, I started to work on migrating to Firebase. First, I made a copy of Heroku working folder, rewrite the Gemfile to remove Heroku specific gems and porting over rack’s config.ru to firebase.json as close as possible. Then I run through firebase serve to verify if the json is working properly as it should be.

In less than one hour, I have it ready to deploy. The guides is very well written and put up together by Firebase/Google. Since I don’t have too many visitors here, I just went ahead with migration and pointed my domain to Firebase.

For web with a lot of traffic, you might want to avoid this.

It took few hours before my blog is ready due to SSL certificate is being provision by Firebase. Until then, a nice invalid certificate warning become the centerpiece of my blog.

Few hours later, I migrated every projects under my belt to Firebase. Its easy to manage when everything is under bucket, and bonus when one bucket fits all need.

With Firebase has its own CDN and enough storage to accumulate all my assets, I deactivated Incapsula CDN and deleted my account on Cloudinary. But the tough one is letting go my Heroku account. It was my first love when it comes to cloud computing.

Some of this commit took place when I was sitting at the beach, enjoying the day.

I have deployed 546 times ever since I signed up. Looking back now, it was a bit emotional because along those numbers, there is a story and memory that I reminisce once in a while. But in the end, nostalgia has no value to keep going.

Share with me your story if you happen to same some on Twitter.

Posted January 12, 2019