school_house icon indicating copy to clipboard operation
school_house copied to clipboard

chore: move from heroku to fly

Open btkostner opened this issue 2 years ago • 3 comments

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

btkostner avatar Aug 04 '22 00:08 btkostner

@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.

kinson avatar Aug 04 '22 15:08 kinson

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.

btkostner avatar Aug 04 '22 16:08 btkostner

@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 avatar Aug 04 '22 16:08 doomspork

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

doomspork avatar Aug 13 '22 12:08 doomspork

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

btkostner avatar Aug 13 '22 13:08 btkostner

@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.

kinson avatar Aug 13 '22 23:08 kinson

@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 avatar Aug 14 '22 03:08 btkostner

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

btkostner avatar Aug 26 '22 20:08 btkostner

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:

btkostner avatar Aug 27 '22 01:08 btkostner

@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!

kinson avatar Aug 27 '22 17:08 kinson

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!

btkostner avatar Aug 27 '22 19:08 btkostner