I am fairly new to fly.io, my python backend deploys using the default settings without any problem by using the flyctl launch.
However, i want to use a python module that uses ffmpeg, i suppose the linux command will be apt-get update && apt-get install -y ffmpeg libavcodec-extra.
I tried to add a section in fly.toml but it doesnt seem to do much.
[build.pre]
# Install FFmpeg using the package manager
command = "apt-get update && apt-get install -y ffmpeg libavcodec-extra"
Could anyone shine some light? I am using the default builder option, btw. Do i have to make my own dockerfile etc?
I don’t think there is an easy “official” way to install packages without a custom Dockerfile (I can’t find any documentation for “build.pre” in fly.toml).
However, there is an unofficial buildpack called fagiani/apt that might be useful – just add the line buildpacks = ["fagiani/apt"] to your fly.toml in the [build] section and create a file called Aptfile with the names of your packages. That should get the job done ;‍)
(Note that this buildpack doesn’t install the packages using apt-get directly and instead extracts them into a custom location. The packages won’t show up in the output of dpkg -l, but they should still be usable because the buildpack sets PATH, LD_LIBRARY_PATH etc. to include that custom location.)
For completeness, I’ll mention that it’s relatively easy to create a custom local buildpack, however installing apt packages is difficult because the build script doesn’t run as root (and can only output to the app directory or to a layer). Here is a minimal example.