Introduction
Welcome to the first post on this blog !
A few years back, I stumbled upon IPFS, the InterPlanetary File System. IPFS is a peer-to-peer hypermedia protocol. In a nutshell, it’s designed to store and share data among nodes running one of its implementations.
I never really had an excuse to use it until now, when I decided to take the plunge and build a website and host it there. To do so, I chose to take advantage of Hugo, a static website generator.
The best way to use Hugo is in conjunction with a Version Control system. My choice quite naturally went to GitHub, where I already host a few projects. GitHub also offers workflow automation tools in the form of Actions, allowing me to automate the building a deployment of this website.
In this post, I’ll briefly present IPFS, Hugo, and the tools that are used to build, distribute and serve this website (all for free, no less !).
IPFS for dummies
The InterPlanetary File System is “a distributed system for storing and accessing files, websites, applications, and data” (quote). It has a lot of very nice properties, among which:
- Content addressing. Each piece of data added to IPFS has its own Content Identifier (CID for short), derived from the content of the file. A CID might look like this (Apollo project Archives):Data being content-addressed means that CIDs are immutable: they always point to the same data. If you change the data, the CID will change as well.
QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D bafybeiccfclkdtucu6y4yc5cpr6y3yuinr67svmii46v5cfcrkp47ihehy
- Decentralization. IPFS, by virtue of being a peer-to-peer system, is decentralized. This means that there is no single point of failure, and makes censorship much more complicated.
- Resilience. Each member of the network acts as both a client and a server, and can redistribute content it has accessed.
Data stored on IPFS can be accessed through one of the gateways that bridge the gap with HTTP, or preferably by running one’s own node in conjunction with the IPFS Companion browser extension.
Hugo in a few words
Hugo is a static website generator, built for performance (not that it really matters, considering the current size of this blog) and written in Go, a language I particularly like. This tool in itself is pretty bare-bones, but offers a lot of customization and a variety of community-built free themes. I currently use Ananke, although this may change in the future as I try to improve my frontend skills.
A quick start tutorial is available in the official documentation here, so I won’t paraphrase it here.
GitHub Actions
GitHub Actions is a service offered by GitHub to run automation workflows for hosted repositories.
I use this service to automate the following steps:
- Building the website,
- Call some IPFS pinning services’ APIs (namely Pinata, but more could be added),
- Push it to web3.storage, a combination storage (FileCoin-backed) and pinning service,
- Update a DNS record (see DNSLink) to make the website accessible from plain ol’ web.
Tying it all together
In conclusion: I combined a static website, a storage solution and a workflow automation tool to build and share a simple website in an unnecessarily convoluted fashion.
Sure, I could have hosted this website on something as lightweight as a Raspberry Pi, or even used a commercial solution such as Fleek, which basically does everything I listed above (and more). I chose to do it this way instead for the learning experience, as well as for the future opportunities this offers (more on that in the next section).
Next steps
So. I have a functional website. Now what ?
Creating problems and throwing CPU power at them
At the time I’m writing this, if you’re accessing this blog using HTTP, you’re going through an IPFS gateway. I set up a CNAME DNS records so that blog.bruyant.xyz points to the Cloudflare gateway (cloudflare-ipfs.com), which offers nice things such as unlimited bandwidth and a free SSL certificate. This, however, has downsides: I’m giving up some control and missing out on more opportunities to tinker with IPFS.
The easiest (IMHO) way to address these issues is to set up one’s own gateway. This is what I plan to do at first, by setting up a VPS running a single instance of IPFS behind a reverse proxy (I’m partial to Traefik). But why stop at a single server, when one could run a whole k8s cluster ?
Building my own Hugo theme
On the theme of relinquishing control: Ananke might be a perfectly good theme, but I’d still like to build my own with a bit more <blink>
, and maybe some background music.
See you in the next post !