elixirschool / school_house

The new era of Elixir School now powered by @phoenixframework
https://elixirschool.com/
Apache License 2.0
155 stars 49 forks source link

chore: move from heroku to fly #198

Closed btkostner closed 2 years ago

btkostner commented 2 years ago

This removes the Heroku stuff and replaces with Fly.io stuff :confetti_ball: This has the added benefit of being clustered to all instances, and actually being able to run multiple instances with Live View. Improve the performance for people in Asia, Europe, everywhere! Plus the community is cooler :sunglasses:

Setup

The GitHub action should work out of the box after you add a FLY_API_TOKEN secret. Docs about that are here.

Once you have the project in Fly.io created, you'll need to add your two SECRET_KEY_BASE and LIVE_VIEW_SALT secrets so deploys stop crashing. That is done with:

fly secrets set LIVE_VIEW_SALT=<blababla>

And past that everything should just work. But where is the fun in that? You can add more regions from the list of platform regions and then

a) scale the app to a hard set number 2) autoscale the app and have it start and kill containers at will

Then just fly status and watch all of your infrastructure troubles melt away

kinson commented 2 years ago

@doomspork this looks cool! Is there any reason you want to stick with Heroku for hosting or are you on board with a switch to Fly?

@btkostner I can take a look at this in the next week (hopefully sooner!) - there have been a few gotchas during deployments that I want to double check with Fly.

btkostner commented 2 years ago

Alright, I have deployed this to elixirschool.fly.dev on the elixir schools org right now. I am noticing some odd libcluster connection issues that I'm going to look into.

doomspork commented 2 years ago

@kinson I'm onboard! I think this would be great. I was talking to @btkostner last night about this on Slack.

Going a step further I think it could be cool to do a blog post for Elixir School on setting your Phoenix app up for fly.io, could be cool to see if they were down to help 🤷

doomspork commented 2 years ago

@btkostner what is left? Would you be willing to do a blog post for Elixir School?

btkostner commented 2 years ago

I think @kinson still wanted to check some some deploy stuff, and I still needed to work out a cluster communication issue.

kinson commented 2 years ago

@btkostner based on my understanding of the docs you shared in the pr, @doomspork will need to add a GitHub secret called FLY_API_TOKEN

Step 3 and 4: Now you have a token you need to make it available to GitHub Actions that run against your repository. For that, there's secrets in the repository's settings. Pop our secret under the FLY_API_TOKEN name and we can move on.

btkostner commented 2 years ago

@btkostner do we need to set a node name for clustering to work? I just saw this in their docs and wanted to double check that we don't need to add that here

Hmm, I thought I did but might have missed something. Let me check again.

btkostner commented 2 years ago

Well, this seems to be more important with the Heroku news coming out.

btkostner commented 2 years ago

Allllllrighty. This PR should be done and good to go. https://elixirschool.fly.dev/

Next step is to setup some DNS records to get a cert provisioned, then update DNS records and :confetti_ball:

kinson commented 2 years ago

@btkostner you have first dibs on writing a blog if you're interested, but if you don't want to I'd be happy to!

btkostner commented 2 years ago

I have a huge backlog of work and personal blog posts I want to do, so I doubt I'll have time. Happy to help and make suggestions though!