A while ago I migrated my Kubernetes cluster from Azure to Digital Ocean. Since then I’ve decreased the size of the workload however costs have stayed the same. Recently I discovered fly.io has a free tier for running containers and in this post I’ll explain how easy it is to get containers up and running using this service.

Running on Digital Ocean

The Digital Ocean workload included some twitter bots that I no longer run because I got sick of maintaining them. Without them or the postgres instance that held their data, only Digital Icebreakers and some development services were left running on the cluster.

Billing however was still coming in at around ~42AUD/month. Here’s the breakdown for October 2022:

Item Hours Cost
(sfo3) (small) (nodes: 1) Load Balancer 349 hours $6.23
1 node - 2 GB / 1 vCPU / 50 GB SSD 672 hours $12.00
(sfo3) (small) (nodes: 1) Load Balancer 394 hours $7.04
(sfo3) - 8.0GB Volume 744 hours $0.80
Taxes (GST Australia)   $2.61
Total USD   $28.68
Total AUD   $42.79

That’s far too much for a single container, so I’d been pondering a replacement host for a while until I discovered fly.io.

Moving To fly.io

Digital Icebreakers needs three main things:

  • a docker host
  • a public ip address
  • an ssl certificate.

fly.io claims to offer all of this for free. Looking into their pricing page details some of the limitations, but the 3 shared-cpu-1x 256mb VMs is impressive. I don’t know of other services that allow running of postgres or docker containers for free without winding them down after some inactivity period.

Getting up and running was absurdly simple. First install the cli tool:

brew install flyctl

Then put this Dockerfile in some directory:

FROM staff0rd/digitalicebreakers:0.6.33-alpha-076976af22
ENV ASPNETCORE_URLS "http://*:8080"
ENV PORT "8080"

Then run a couple of of fly commands:

fly auth signup # to create your account
fly launch # to create and deploy your app

After this, the app is available on the internet via a *.fly.io url. To add your own domain with an SSL certificate run:

fly certs add yourdomain.com

The output of this command will include the DNS entries needed by fly/letsencrypt to point to your app and validate your domain ownership.

Other CLI commands

The CLI tool also has a bunch of other commands which make working with your infrastructure pleasant.

See all your apps with

fly list apps

And while you’re in a directory of an app, see its logs (similar to docker logs) with

fly logs

To ssh into the VM run

fly ssh console

Conclusion

I’m impressed by the simple onboarding journey and the very handy CLI tool. I’m also interested in seeing if I can run a postgres instance at no cost. Pricing above the free allowance appears to be just under what Digital Ocean charges for droplets. Overall I’m looking forward to seeing how fly.io stands up as a host over the next few months.