Fly CLI in Dockerfile?

I have been trying to get fly installed on my Phoenix app’s machine, but my Docker skills are a bit rusty. The shell script appears to be installing since I can export the FLYCTL_INSTALL and PATH env vars can be exported manually in the remote shell.

▶ fly ssh console --pty
Connecting to YADAYADA... complete
root@YADA:/app# fly
-bash: fly: command not found
root@YADA:/app# export FLYCTL_INSTALL="/root/.fly"
root@YADA:/app# export PATH="$FLYCTL_INSTALL/bin:$PATH"
root@YADA:/app# fly
This is flyctl, the Fly.io command line interface.

Usage:
  fly [flags]
  flyctl [command]
...

Here’s the relevant Dockerfile code:

https://github.com/type1fool/wildfire/blob/5339b2161f63fdba4f8fcd8a2d1afb4ce4f56e4c/Dockerfile#L74-L77

The reason for installing the CLI is to list the Fly regions since there doesn’t appear to be a public API for this. This will allow me to perform ad-hoc latency measurements using a variety of protocols.

Needless to say, it works on my local machine :clown_face:.

Try this:

FROM flyio/flyctl:latest as flyio
FROM ${BUILDER_IMAGE} as builder

. . .

COPY --from=flyio /flyctl /usr/bin

Note: that will create an executable named flyctl. If you want fly, create a symbolic link.

1 Like

That worked! Thank you, @rubys !