flyctl deploy with nx monorepo

Hello,

I am deploying multiple NestJS microservices to Fly from an nx monorepo. They are each deployed as a separate Fly app and with a separate Fly.toml/Dockerfile. I’d like to place my fly.toml and Dockerfile in the same directories as the subproject apps/microservices. However, my docker build context must run from the root of the monorepo, not inside of the apps/microservices folder.

How can I set the docker build context when doing flyctl deploy?

Example structure (I need to set the docker build context to ./root and do a deploy from 1 of the fly.toml files).

./root
   apps/
      microservice1/
         Dockerfile
         fly.toml
        // package.json, etc...
      microservice2/
         Dockerfile
         fly.toml

As a workaround now, I’ve moved fly.toml to the ./root and pointed it to my Dockerfile in the sub directories.

Thanks.

flyctl has a few options to specify paths to fly.toml, Dockerfile, and the build context: Monorepo and Multi-Environment Deployments · Fly Docs

Are those not working?

I have a similar issue but with dotnet.

~/
    src/
        MyApp.Http
        MyApp
fly.toml
Dockerfile

I normally build my app with

docker build ./src

After reading the link described by @michael for mono repos I tried the following

fly deploy ./src --config ./fly.toml
Error: the config for your app is missing an app name, add an app field to the fly.toml file or specify with the -a flag

ahh! ok. the magic incantation was

fly deploy ./src --config ../fly.toml

would have been nice if it said that it couldn’t find the file, rather than saying my file was missing something that it wasn’t. :slight_smile: