Inspiration
I had started learning Rust in the past month, and was excited about how easy it was to generate HTML docs using rustdoc. I had previously set this up via GitHub Pages to test it. However, when I learned about the MLH DigitalOcean promo, I was excited to try this out on DigitalOcean as well.
What it does
Hosts docs generated by rustdoc + a GitHub Actions workflow as a DigitalOcean static site!
How we built it
I had previously worked on a FizzBuzz code golf project to test my Rust knowledge last month as I just started learning this language. As part of this exploration, I was learning how to use rustdoc to generate HTML docs from comments in the Rust code. I ended up creating a GitHub Actions workflow to generate and publish these as a static site on GitHub Pages. The way it works is using gh-pages branch to commit the contents of target/doc, which are the static HTML, CSS, and JavaScript files needed to host the docs static site.
DigitalOcean made it simple to import these directly from that very same GitHub branch!
Challenges we ran into
I played around with DigitalOcean app settings, "HTTP Request Routes", and "HTTP Routes Redirect". However, the redirect rules proved a bit tricky to get right, given the file structure and layout which I had originally designed for GitHub Pages. I quickly found that I could accidentally create HTTP redirect loops, and backed out those changes. I found that with this directory layout and configuration, the root / index route shouldn't be used, and instead simply go directly to the rustdoc root for the project: /fizzbuzz.
In practice for future production-worthy projects, I'll have to remember this.
Accomplishments that we're proud of
Spun up a static site with DigitalOcean in no time! As a plus, it looks like they provide a CloudFlare CDN caching layer for speedy load times too! (based on HTTP responses mentioning CloudFlare headers)
What we learned
It's pretty easy to deploy static sites on DigitalOcean. Also, it's pretty easy to accidentally create 302 redirect loops. 🤦
What's next for rustdoc static pages->DigitalOcean
Probably not much. This was just an exploration for me to learn how DigitalOcean hosts static sites. I'll probably stick with GitHub Pages for this toy code golf project, because I'd rather not use one of my 3 free static sites for it.
Built With
- digitalocean
- github-actions
- rust
- rustdoc
Log in or sign up for Devpost to join the conversation.