Is there a way to deploy to multiple Apps using the same code

The reason I want to deploy the same code (api server) in multiple apps is because each app has a different IP, my api server calls a different public api and has a very tight api rate limit based on ip and the way I’m currently trying to do this is manually typing this every time

fly deploy -a app1
fly deploy -a app2
fly deploy -a app3

is there a better way?

  • Here is a method in shell script

# Define an array of app names
apps=("app1" "app2" "app3")

# Loop through each app name and deploy
for app in "${apps[@]}"; do
    echo "Deploying to $app..."
    fly deploy -a "$app"

chmod +x
  • Here a python method
import subprocess

# List of apps to deploy to
apps = ["app1", "app2", "app3"]

# Loop through each app and deploy
for app in apps:
    print(f"Deploying to {app}...")["fly", "deploy", "-a", app])

  • Here is a node method
const { exec } = require('child_process');

const apps = ['app1', 'app2', 'app3'];

apps.forEach((app) => {
  console.log(`Deploying to ${app}...`);
  exec(`fly deploy -a ${app}`, (error, stdout, stderr) => {
    if (error) {
      console.error(`Error deploying to ${app}: ${error}`);

node deploy_to_multiple_apps.js

Thanks for this <3

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