Run app without a web server or a long running process, just to run tasks via ssh

Like the title says, I want to run an app that’s simply going to contain a directory of scripts that interact with resources in the network that are accessible via our private net, but not from outside.

What’s the best way to deploy this? Do I need an ENTRYPOINT or RUN command in a Dockerfile with an infinite loop? Can the machine sleep and only start when invoked via fly ssh console?

I haven’t done this myself so if someone else have more tips please join in but here’s the general tips for what you’d need:

  • Do not put [services] on your toml. Those are for web services and your release would fail unless you listened to a port of your choosing.
  • Make sure you don’t have public IPs. We generate those only if you have [services]. If you do you can fly ips release [IP] no worries.
  • Maybe you’d need an entrypoint/cmd but that could just be something like while true; do sleep 1; done (I feel like I’ve seen a better one, maybe sleep inf?).

Hope this helps.

Thank you @lubien

What worked:

  1. Create a simple fly.toml with just app_name and primary_region
  2. Add an ENTRYPOINT to the Dockerfile that runs an infinite loop:
ENTRYPOINT ["tail", "-f", "/dev/null"]
  1. Manually scale the app to 0 when finished. fly scale count 0 -a name-of-the-app
  2. Run a deploy when I need to run a script again.

Maybe you can just scale count to 1 or just fly machine start -a appname [machine_id]?

That used to work in v1 apps (scale count 1), but when I do scale count 0, the machine is destroyed, so there’s no way to start it up again. Is there an easier way to start a new machine for a given app?

You can manually stop the machine using flyctl and then you’re able to bring it back later with the start command with no need for a deploy.

1 Like

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