Fly + Docker Compose: “only one service can specify build”

Hi… The Docker Compose compatibility layer is still fairly basic, and the fact that only one container can do a build is a known limitation, alas. You don’t have to put everything in separate Machines if you don’t want to, but you would need to build and push at least one of the containers’ images as a separate step.

Alternatively, it’s probably worth looking at Fly.io’s own [[statics]] feature; that might be able to replace your Nginx container entirely. The /api/ subtree, if I’m reading the official docs correctly, would just fall through to your dynamic server, provided it’s not present in the specified static directory hierarchy.

For context, it’s probably worth at least skimming the following official doc, too, even though those older techniques are maybe not the first choice in this case:

https://fly.io/docs/app-guides/multiple-processes/


I would be remiss for not warning about single-Machine Postgres here as well: this is very dangerous on Fly.io’s Machines platform and more or less guarantees permanent data loss in the future, :dragon:. (Or, at very least, a highly stressful manual data-rescue operation.)

It’s best to use Managed Postgres instead, unless this is only throwaway data or you have streaming backups set up, etc.

1 Like