How to: Reliable hosting and deployments for free

Gaurav Saini
4 min readNov 14, 2020

--

As a person who actively maintains multiple personal projects deployed on multiple servers, it became a necessity for me to find a cheap and reliable resources.

About a year and a half back, I thought of making my portfolio website. Within a couple of days I figured that hosting a website is an expensive deal! Especially if one wants to get out of Apache based shared Linux hosting that can either run static websites, or is limited to using a language like PHP. While PHP is a great language, it isn’t my choice for web development. Hence I had to find a way to run my Golang server that powers the UI written on Vue.js. One solution was to get the unlimited power, i.e. spinning up a VM on a cloud and running Golang server there. It’s truly a fantastic! Except when you get to know the prices. These start from $5 per month. The cloud service providers also give some services for free. While, I have enjoyed my time using free cloud services from Digital Ocean, AWS, Azure, and GCP, they are all time bound. Some offer free services for 2 months, others do for a year at max. I had to find cheaper (free would be great!) resources for my projects that involve web development primarily.

Here is the list of free resources that power my portfolio website alongside some tricks to squeeze out extra, within the free tier. I will divide this list into 2 parts, the infrastructure and the software packages

Disclaimer: All these services are meant for non-commercial use or otherwise stated in the license agreement. Please read and understand the terms carefully.

Infrastructure

  • Heroku Cloud: Heroku is one of the most easy to use PaaS solutions out there. Best part? The lowest version is free! It includes a host name (Subdomain on herokuapp.com) and shared a SSL. It requires a credit card for registration, but as long as you don’t opt for more powerful deployment server they don’t charge. It’s definitely one great solution! However, it does limit in terms of technologies that run your app. For me, I could deploy my code as a Golang application, but there was compilation of Vue.js involved. How did I get around this? Using Docker. Details are discussed below.
  • Cloudflare: If you have a domain, Cloudflare free tier gives superfast DNS, assets caching, free SSL, and CDN. Cloudflare also does redirection based on URL pattern, but there is a limitation on the free tier and protects against DDoS.
  • Database: With Heroku, you can get numerous free add-ons. It includes PostgreSQL, MySQL, etc. However, since I have been using the free tier MongoDB Atlas for almost 2 years now, I went with it. Know that there are numerous options available in free tier.
  • Mailgun: Do you need to send out emails for free? This might fall under extended requirements, but yes, Heroku does offer a free tier Mailgun account that can be used free of cost. Mailgun has SDK available in numerous languages and can be integrated easily to send out emails from your application.

Software

  • Docker: As I had mentioned above, Heroku is great as long as your app is written on one technology only. However, Heroku supports docker based deployments as well, that’s where the real flexibility comes into picture. My portfolio website is registered as a Docker based app on Heroku. The docker file that I have written, uses Golang image as base and builds Golang code, then downloads Node.js, builds Vue.js code, and copies the built assets on an alpine linux distribution. This lets me use theoretically any tech stack for my application, which is limited by using a tech-specific language pack on Heroku.
  • TravisCI: Don’t like building your code on development machine and copy files over to server or build code on PaaS again? Wire up a Travis pipeline to do it for you! It’s free as long as your project is open source and is merely a few clicks and a small script away from getting up and running.
  • Github: The ease of integration with all the above mentioned services is the sheer power of Github. Push code to main branch, the code is built on TravisCI (or any other CI that you are using) and upon a successful build, the website is deployed on Heroku! Big firms more or less set up similar pipelines for their production systems.

Till now, we have arranged for running a website that runs on https://<app-name>.herokuapp.com , however, if you have a custom domain, Cloudflare will come extremely handy in making website secure on a custom domain using the shared SSL and will also speed up quite a lot!

Conclusion

All the services that I mentioned above are available for free at the time this post was written. You need not spend a single penny to get these running. However, one thing I recommend doing is spending money on getting a domain name. A small investment on domain name to utilize the power of Cloudflare is worth it. Especially when a single Cloudflare account can be used to host multiple domains.

Need more help?

Head over to https://gaurav.app and drop me an email! I’ll try my best to help!

--

--

Gaurav Saini

SMTS • Web Services • Rust/Go/Py/JS • Cloud & Distributed Systems