Multiple orgs for different app codebases

Hey, currently I have a personal organization for my hobby project in Elixir that is under my personal email for auth purposes. I have another app to be deployed, different codebase that probably will require one org for production and one for staging. What is the best approach to handle this scenario and have flyctl working between them? Does it matter I have two different accounts (personal email and company email) for command line authentication?

flyctl supports an environment variable FLY_ACCESS_TOKEN, which overrides the default login token stored in ~/.fly/config.yml.

From the Web UI, you can create a named access token (this is what fly auth does internally)

I use direnv to manage multiple Fly accounts - I stay logged into my work account, then I have a Personal directory that has an .envrc file in it that looks like

export FLY_ACCESS_TOKEN=some_token

It’s not the simplest thing to set-up, but once it’s done once, you never have to worry about it again. Pretty nice!

(of course, you can also just fly auth logout; fly auth login to switch accounts on-the-fly, but that gets a little inconvenient when you’re swapping back and forth a lot)

1 Like

assuming I can use my current auth email and avoid this part, what is the suggestion for having one codebase to be able to be deployed to two different orgs (one for prod and one for staging)? Pretty much what I need is to mimic what Heroku offers through multiple git remotes.

I’d just have an app called, for example, my-app-prod and my-app-staging, and when deploying to one or the other target it with fly deploy -a <appname>. It doesn’t matter which org any of those are in, as long as the currently auth’d user can deploy to that org.

Is that what you were looking for?

1 Like

That works for me, but looking at fly.toml there is a line with app = "my-app-name" so I am not sure if this line is ignored, as it might work as default, or not when deploying using the -a <appname> flag.

The -a flag will override the app name specified in the config, but will reuse the rest of the config. This will not change the toml file.

If, however, that’s not desired behavior, you can specify a path to a different toml file with -c <path>

1 Like

Thanks, I think I have all I need, appreciate the help.

1 Like

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