If you are deploying to Fly.io using a Dockerfile you can run the Akita CLI within that container to observe your API traffic. The instructions below walk you through the necessary steps.
If you are using Fly.io to deploy an application from source code, this method is not available. See Generating API Models without Packet Capture for some additional options.
The Akita CLI will run inside the Docker container you build for deploying your application on Fly.io. Install the Akita CLI during your container build process by running the install script or downloading a package from our repository. See Install on Linux for additional details.
For example, on most Debian-based images, the following command will install the latest version of the Akita CLI:
RUN bash -c "$(curl -L https://releases.akita.software/scripts/install_akita.sh)"
Next, change your container's default command to the Akita CLI. The apidump subcommand lets you run your application's normal startup as a subprocess. The packet capture will run continuously, and stop as soon as your application exits.
Use the project name you have created on the Akita console; see Set up the App for instructions on creating a new project.
CMD ["/usr/local/bin/akita", "apidump", "--service", "<your project name>", \ "-u", "root", "-c", "<your normal commnand line>", \ "--rate-limit", "1000"]
We recommend starting with a relatively low rate-limit, because this limit is applied to each running container, not to the application as a whole.
Alternatives to modifying the entry point
You can also run the Akita CLI as a background process, if your normal entry point is a script. Run
akita apidump --service <your project>in the background, and the Akita CLI will start continuously monitoring all traffic to and from the container.
The Akita CLI needs to access your API Key (created in Set up the App) to send traffic to Akita. If it is not able to authenticate with the Akita cloud servers, the CLI will immediately exit.
The best way to set the API key is via a Secret, which is passed as an environment variable to the container From the command line, add new secrets called
AKITA_API_KEY_SECRET with your key's values filled in:
$ flyctl secrets set AKITA_API_KEY_ID=apk_xxxxxxx $ flyctl secrest set AKITA_API_KEY_SECRET=xxxxxxxxxx
You will see a hashed version of the secret in your Fly.io activity log.
After adding the Akita API key, use
flyctl deploy (for an existing application) or
flyctl launch (for a new one). This will build the new version of the container that contains the Akita CLI, and deploy it to Fly.io as a new revision of your application.
Updated about 2 months ago