Fork me on GitHub
#biff
<
2022-12-18
>
Jacob O'Bryant01:12:46

Well I got biff deployed to http://Fly.io. You just stick https://gist.github.com/jacobobryant/d3b2654c36161414a7b6a306b3f678b5 in your project and run flyctl launch like normal. You do need to upgrade to at least 1 gig of ram (`fly scale memory 1024`) and make sure :biff/base-url in your config.edn file is set to whatever domain Fly gives you. To connect to prod over nrepl, run flyctl proxy 7888:7888 , same as running bb prod-repl previously. Edit: you also need to add this section to fly.toml:

[env]
  BIFF_ENV = "prod"
Another edit: also put this in config.edn:
{:prod {:biff/host "0.0.0.0"
  ...
Now that I've verified all the essentials are working, starting next week I'll begin updating the code + docs to use Fly by default. I'll need to figure out what develop-in-prod will look like. There's not a way to get around the fact that if the app restarts it'll get booted in a fresh container, but, eh. I'll leave in the instructions + code for DigitalOcean as an alternate option. If most people are happy with Fly, then after a while I might move the DO stuff to a blog post.

🙌 1
🔥 1
🚀 2
Jacob O'Bryant01:12:35

I am quite impressed with Fly. I'm planning to migrate my Platypub instance to it, and at some point I might move Yakread there as well.

Lyn Headley03:12:58

What is the value of fly over DO?

Jacob O'Bryant04:12:42

it's easier and faster to deploy stuff with less room for stuff to go wrong. A small secondary benefit is that it has some nice scaling features for when/if you're ready to go beyond a single machine. it's even a bit cheaper than DO, at least at some tiers. e.g. a 1gb shared cpu instance is $5.70/month on fly, and it's around $7/month on DO I think. I previously looked at container-based deployment solutions for Biff, but price was prohibitive. e.g. Render markets itself as a cheaper heroku, but it's still twice as expensive as DO droplets for a given amount of memory. which can really add up... my monthly DO bill is already over $300 since I have so much random stuff on it. so for a while I figured that container-based deployment would just always come with a price premium--even DO has their App Platform thing which is a bit cheaper than render, but not by much--and thus might as well stick with plain VMs on DO, and switch to containers only if you're scaling out and the reduced devops burden is worth the extra cost. I think it was just a month or two ago I noticed that fly pricing is actually competitive with VMs, which is what started me thinking about using it as the default recommendation.

Mario Trost18:12:25

This is very cool, testing it out right now

🎅 1
Mario Trost19:12:42

No luck so far:

$ Successfully installed clojure tools!
$ Checking out:  at 6353c406adef0344484b49a5ef2282eab77c2347
$ Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
$ Could not locate com/eelcht__init.class, com/eelcht.clj or com/eelcht.cljc on classpath.

Mario Trost19:12:27

👆That's the error in the created app when trying to deploy

Mario Trost19:12:01

Hm, wait, perhaps I did some changes I don't remember 😄

Mario Trost19:12:01

Nothing obvious for me, I'm off now, looking into it later in the week

Jacob O'Bryant19:12:06

Just realized there was another step I forget to mention--you need to add this to fly.toml:

[env]
  BIFF_ENV = "prod"

Jacob O'Bryant19:12:56

however I don't think that's causing the error you're seeing

Jacob O'Bryant19:12:07

do you have a typo in config.edn? e.g. is :biff.tasks/main-ns set to com.eelcht instead of com.eelchat?

Jacob O'Bryant19:12:13

I'm assuming that's causing the error, unless you actually did use com.eelcht as the main namespace when creating your app.

Mario Trost19:12:29

reading error messages really helps 😄

😉 1
Mario Trost19:12:32

testing it again

loganrios20:12:19

We’re using a Linode Alpine 3.17 VPS on our end—a lot of the Digital Ocean sections helped us out with setup. I’m a little biased against Heroku-likes personally, but I am interested to see how the http://Fly.io journey continues!

Jacob O'Bryant20:12:06

👌 I'll update towards leaving the DO setup script + docs in the main repo/website then, and keeping them up-to-date.

❤️ 1
Jacob O'Bryant20:12:48

I have been wary of container-based deployment platforms and the like myself--they're nice until something breaks, or you have to work around some limitation... I've become quite attached to plain VMs/DO droplets for that reason. Much fewer moving parts than when I was running on datomic cloud ions + aws 🙂 . I have gotten good vibes from Fly. I think they might actually be getting things just right so it's easy without boxing you in. An example being connecting to prod over nrepl--works on fly but not on heroku (my understanding is that you can do it on heroku if you use a nrepl-over-http lib, but there isn't much editor support for that...). So I'm cautiously optimistic that I'll be able to start using Fly for all my own stuff without giving up control. Though I won't be moving my main app over until I've had more practice with other apps.

loganrios20:12:06

At the risk of sounding like a noob, the few run-ins I’ve had with AWS had been pretty intimidating and complex, so I did love coming across Biff’s documentation where it proudly declared that you could run everything from a $5 VPS—and that doing so was well-documented. Big initial selling point for me (although once I dug in, I found a lot more to love). Agreed with the “good vibes” about Fly, though—the founders are very friendly on HN (that I’ve seen) and I do love that it seems to be created by (and partially for) the Elixir folk (who are basically cousins to Clojurists imo). I could see switching if they can solve scalability easier than a VPS without crazy pricing and AWS/Azure/GCP-tier complexity—hence my investment in following your experience 😅

🙌 1
Mario Trost20:12:47

Strange, system started, last log message is nREPL server started on port 7888 on host localhost - , but app stays in error state. Now I'm really off for today and looking into it later in the week, thanks for the support!

Jacob O'Bryant23:12:58

hm! Must be another loose end somewhere. Happy to help debug later. Hopefully by this weekend or the next I'll have some more complete/polished/tested docs for deploying to Fly as well.

Jacob O'Bryant01:12:58

OK I just remembered another thing you're supposed to do, which is most likely the cause of the error. You need to put :biff/host "0.0.0.0" in the :prod section of config.edn. On DO, nginx forwards requests to localhost:8080, but on Fly the app needs to listen on 0.0.0.0.

Mario Trost05:12:24

🔥 that worked

Mario Trost05:12:18

And now remembering from past Fly adventures 😄

Jacob O'Bryant07:12:17

👌👌 there is one final step which I didn't get around to doing myself: setting up a volume for the storage folder. without that, your data will get wiped whenever you deploy.

👍 1
Mario Trost07:12:59

still going through the tutorial, but good to know! One small stepping stone running fly launch : when asked if you want to create a .dockerignore from your .gitignore, answer with no or remove config.edn fromthe created file afterwards. Perhaps worth mentioning in the instructions when you start writing them.

Jacob O'Bryant07:12:27

ah yes I'll be sure to mention that in the docs

Jacob O'Bryant07:12:56

maybe I'll just add a .dockerignore file to the repo myself

👍 1
Mario Trost08:12:59

Yeah, adding a .dockerignore makes more sense I guess!

tbrooke21:12:56

@foo Let me know when you get platypub up on http://afly.io.

Jacob O'Bryant22:12:12

Yep, I'll definitely make an announcement about it

tbrooke13:12:35

Great - I am using it locally for my Church CMS and ready to set it up to delegate to Church Staff

👌 1