Issues deploying to Fly.io
I'm trying to deploy to Fly.io, but I keep hitting this error:
I created a deploy key in my prod settings on the Convex dashboard. I read in the Fly docs about adding build secrets, but frankly the instructions feel incomplete/inaccurate:
* It says that I have to first mount the secret via a directive in the Dockerfile. However, after the example code, it says, "This creates a new file when running
docker build
"—which it doesn't. I had to create that file myself and put the key into it, or else I just got an error that it couldn't find the file.
* The docs then say that I need to also pass the key when calling fly deploy
, which feels redundant. If the key is in the file and the Dockerfile is configured to read it, why must I also pass it via a flag? Also, that doesn't help with the initial deployment using fly launch
.
Command-line tools aren't my strong suit, so I'm not sure what else to try.13 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Convex deploys separate from your app that goes into Fly. Are you deploying manually via the CLI or in something like GH Actions?
I'm using
fly launch
per the Fly docs, but that configures GH actions by default, so I guess it's a mix of both. I just went with the default settings the first time I ran fly launch
, but when that failed (not surprising) I changed the Dockerfile to use RUN npx convex deploy --cmd 'npm run build'
for the build command. That's when it started throwing those deploy key errors that I haven't yet been able to fix.Yeah there’s an api key that needs to be set as an environment variable to make the deploy work. I just stepped away. Mind if I follow up tomorrow morning?
You need to put the convex deploy key in the environment variables of fly not the convex dashboard
Just to be clear, my mention of the Convex dashboard was just to indicate that I'd created the deploy key there. I then tried to set that key in Fly, but it didn't work.
I first tried using the
fly secrets
command, but that command only works after the initial launch of the app. I then found the mention of separate build secrets in the Fly docs, but not only did the breakdown leave me scratching my head, it only mentions its use with fly deploy
. It doesn't account for needing that secret during the build phase of fly launch
.Am I to understand that I need to launch the app with
fly launch
knowing that it's going to fail during the build phase, then run fly deploy
with the secret? That just doesn't make sense. There must be some other way to pass the key to Fly during the build that I'm not finding.
FWIW, I also tried adding the Convex deploy key to the env
section of the fly-deploy.yml
file, but that also didn't work.
I dug into the docs for fly launch
and found that it also accepts the --build-secret
flag that's mentioned for fly deploy
. So I went ahead and tried the process mentioned on the build secrets page linked above. Still fails.Personally I deploy to Convex separately in my own setup. I'm using GitHub Actions to run one script that deploys the Convex app, then another that deploys my Remix app to Fly
Is there a reason you need to do them at the same time?
Rather, in a single command
I'm only going the single-command route because that's how I ended up doing it with the initial test I ran on Vercel (because I believe that's what the Convex guide for Vercel recommended). I assumed the same process would pretty much apply anywhere else.
I've not used GitHub Actions, so I'm not sure where to begin with that side of things.
Is that the only way to make it work on Fly? Deploy the app separately from the Convex deployment?
If I switch the build command back to the standard
npm run build
and manually deploy Convex, there are no errors in either process. However, the app fails on Fly with a 502 error.
Checking the logs on Fly, I see this:
Aside from my earlier attempt to have Convex deploy in the same command as the build, I haven't touched the Dockerfile settings based on what was originally built by the Fly CLI.
If it's not already painfully obvious, server config is my kryptonite. If some patient soul could kindly help me get through this, I'd be most grateful.So I have to ask - given the whole kryptonite mention, is Fly a requirement for your use case or do you have the option to use something like Netlify instead?
Fly isn't a requirement. It was recommended as another option that might end up being free if my usage of the app is low enough. It's just a personal app, so free hosting is preferable. I had an earlier test of the app working on Vercel, and I'm thinking of returning to that considering the Fly experience so far.
That said, I'm also sorta-kinda taking various hosting services for a test run because some time next year I'll be launching a major app for work. Our current stuff is on DigitalOcean, but I've been keeping my eyes open for other options, as the service there has proven to be a little unreliable at times.
This work app will also be built using Convex, so finding a host where the deployment is as easy as possible is pretty important.
Pairing Convex with Netlify or Vercel would really free you up to stop thinking about your infra and just focus on your product. Unless you're someone who is very familiar and comfortable with configuring, provisioning, and maintaining services, there's a case to be made that doing so for potential cost concerns is premature optimization.
Great points. I'm currently the lone dev at work, so by default I have to cover all the bases, and this latest round of app tests has really shown me where I'm lacking. I'll likely stick with Vercel for the personal app and DigitalOcean for the work stuff for the time being, and hope that we can eventually bring someone else on board who's more versed in those other areas.