January 5, 2020

How To Make Your Website Truly Serverless

As of today you can read this website without a web server by visiting dat://roborooter.com. If that link doesn't work for you, you'll need a DAT capable browser like Beaker Browser. And in early 2020 you probably don't have a DAT capable browser yet, so go get that. While I've been working in the serverless world a while, this is actually without servers and much more deserving of that name.

The difference between the DAT version of this site and the https version of this site is where you get it from.

When you visit Roborooter via HTTPS your web browser is asking a company named GitHub for the site, you're trusting GitHub to give it to you, and to give it to you without monitoring what you're doing, tampering with my content, or refusing to serve it to you. GitHub in the past has blocked whole countries and routinely removes content with nothing more than an automated DMCA request. So you never know, I could piss them off.

When you visit Roborooter via DAT your web browser is joining a decentralized network of web browsers and requesting this site from anyone that might have it. It's cryptographically secure (I have a DNS record pointing to it's key b6444dadf8499f1511855ddc4c8816f1b5ea9de4e732aea3899dc14d30422d8d) so you can trust that whoever gives you this site is actually giving you my site. It's distributed so as long as at least one person on the internet cares about this website you'll be able to retrieve it. And while whoever shared the site with you knows they gave it to you, and whoever has the site may know you've asked for it, that's about the limit of the monitoring that can happen.

The DAT Project started to help scientists share large files with one another. If you're familiar it's like git+bittorrent. With Beaker Browser, you can use dat to view DAT sites. It's got a lot of great ideas baked in, like being able to publish a website from the web browser, fork other websites, have them modify themselves, and make applications that are entirely offline.

For a great overview I highly recommend Tara Vancil's JSConf EU 2018 talk Imagine This: A Web Without Servers.

There's still one part of this story that bugs me.

...as long as at least one person on the internet cares about this website you'll be able to retrieve it.

I'm probably that one person for this website, it's not super popular. So how do I keep it available? I can;

  • Click "Seed this site's files" in Beaker Browser and always have my computer on and online
  • Pay a company like hashbase.io to "pin" the archive so it's always online
  • Run DAT on a computer in my house that's always online.

I went with the last one. If you're reading this via DAT, then you probably got it from a Raspberry Pi that's in my basement. If this is some future where Roborooter is very popular, then you might have gotten it from a neighbor. But that probably hasn't happened yet, so it's my basement.

dat pi

Now isn't this a server? Sure, but the only thing that's special about it is that it's always online. It doesn't have any more authority, access or capabilities than anyone who's sharing Roborooter over DAT. It's just another computer in the network.

I run this PI using a service that I will forever remember as the service formally named Resin.io becurse I can't say or spell their new name, Balena. Balena is a docker on embedded devices platform that lets you git push to it. I'm really surprised I've never written about them before. They helped make former projects like "The Reconbot" (a robot I did for Intel at makerfaire) possible. I have a simple setup that took forever to figure out. I call it the Home Server and I'm sharing it here. Right now the list of Dat repositories to mirror is in an environment variable and you have to login to Balena to change it. Dat itself seems like an obvious way to keep that up to date in the future.

dat pi

The hardest part was figuring out that currently DAT requires host mode networking in docker. I'm writing that out here because if you want to know this you need more links pointing you to that github issue.

This whole project was harder than I'd like it to be. Beaker is great, but having a decentralized life on the web needs more to it. Maybe there's a future where everyone has or rents a capable "home server". Thankfully many people are working on it. I'm really proud and happy DAT and Beaker exist. It's helping me have the internet I wish we had.


Roborooter.com © 2024
Powered by ⚡️ and 🤖.