🛫Deployment

Deployment with Fly.io

We have found Fly.io to be the best combination of cheap and easy. Petal Pro has been set up for users to quickly deploy on Fly.io's servers.

If you haven't already, download the Fly.io CLI. Then you will need to register or sign in.

Once signed in, you can create a new project with:

fly launch

Give your app a name (this can't be changed in future). Hit Y to setting up a DB as we'll need that. Pick a server size. When it asks "Do you want to deploy now", hit N - we need to make a couple of changes before we deploy.

Firstly, open Dockerfile and look for RUN mix assets.deploy.

Since we're using tailwind, this step involves the Tailwind CLI scanning our files for CSS classname that it will include in the final app.css file. A problem with the default Fly Dockerfile is that it runs this command before the lib directory has been copied over, so it misses all of our CSS classnames in our HEEX files!

To fix this, simply move the assets.deploy command underneath the COPY lib lib command.

Secondly, we need a service to send our emails out. We've found that the simplest and cheapest solution is Amazon SES, and so Petal defaults to using this. We don't really use Amazon for much else, but it's email service is cheap and the emails don't get sent to spam as easily as other services we've tried.

Setting up Amazon SES is beyond the scope of this guide - you can google how to do it. The end result should be you being able to provide the following secrets that we'll provide to our production server:

fly secrets set AWS_ACCESS_KEY="xxx" AWS_SECRET="xxx" AWS_REGION="xxx"

Finally we can run fly deploy.

After deploying you can run fly open to see it in your browser.

Last updated