Deploying Only My WebSockets Server to Fly.io Without Separating Client and Server Projects

I’m currently working on a project where my WebSockets server is contained within my client application, but for deployment purposes, I only want to deploy the server to Fly.io. I’d like to keep both the client and server in the same repository for development convenience but ensure that only the WebSockets server is deployed.

My Setup:

  • Monorepo-style project: Client (React/Next.js) and WebSockets server (Node.js with WebSockets).
  • Fly.io deployment: I only want to deploy the WebSockets server and not the client.

What I Need Help With:

  1. How can I configure fly.toml or my deployment commands so that only the server directory gets deployed?
  2. Should I use a [build] section in fly.toml to specify the working directory?
  3. Are there any flyctl commands that allow me to push just the server while keeping everything else in the same repo?
  4. Any best practices for keeping both together in development while ensuring a clean deployment?

Would appreciate any insights or examples from folks who have tackled a similar setup!

This is probably a Docker problem rather than a Fly problem. How to solve it depends on what you have presently.

If you currently have a Docker image that runs locally that serves both projects, I would split it into two projects that inherit from one another. So, make one Docker image that serves one project, and then another Docker image that inherits from the first, and adds the second project.

You can then:

  • Use your second image for automated testing (assuming that your app only works if both parts are available)
  • Use your first image on Fly with just one project
  • Deploy only on Fly if the automated tests pass in your CI stack

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.