I’m getting started with Fly.io and Phoenix and am curious if anyone has managed to set up their deployments in a Vercel-like fashion?
I.e. Any pushes to main
are production deployments, and any other branches are preview deployments
I’m getting started with Fly.io and Phoenix and am curious if anyone has managed to set up their deployments in a Vercel-like fashion?
I.e. Any pushes to main
are production deployments, and any other branches are preview deployments
There isn’t a pre-built script to do this right now, but it is possible to set this up using Github Actions integration: Continuous Deployment with Fly and GitHub Actions
There’s a little more nuance with backend applications and preview deploys, like do you want the same secrets set on your preview deploys as well, or some kind of preview secrets template; which database you might want to connect the previews etc. Do you have any thoughts on details like that?
Ideally there’d be a separate database and set of secrets for the preview environment(s).
On Vercel you specify what environment the secrets apply to (DEV, PREVIEW, PRODUCTION).
Is the most trivial approach to have a separate project that is constantly overridden by the latest branch deployment? Then set up another GitHub workflow to watch for branches (excl. main)?
+1 for this feature! I’m trying to figure this out right now. If I set up a github action, isn’t it just deploying my app to the same instance I just deployed production to? Ideally I need to push to preview/staging first, then production. I guess I’m wondering right now, how do I tell my React app to push to a second app i’ve created on fly.io that is separate from my production app?
You can specify a different fly.toml
, like args: deploy -c fly-staging.toml
. Would that work for you?
Ahh this is great. Worked perfectly!! So simple thanks!
I’m only just coming back round to look at this now.
So is the gist of it that you set up a second GitHub action + config file? Like below (which I have not tested yet)
main.yml
name: Fly Deploy Production
on:
push:
branches:
- main
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
deploy:
name: Deploy production app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: superfly/flyctl-actions@1.1
with:
args: "deploy -c fly.production.toml"
preview.yml
name: Fly Deploy Preview
on:
pull_request:
branches:
- main
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
deploy:
name: Deploy preview app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: superfly/flyctl-actions@1.1
with:
args: "deploy -c fly.preview.toml"
Happy New Year, yo!
Yeah, looks like it.
In addition to the link that @sudhir.j shared, https://fly.io/docs/reference/monorepo/#examples