Dokku and ffmpeg

Thursday, February 20, 2020 3 min

Dokku is a small PaaS that acts Heroku like. Basically this means it supports Buildpacks to provide the software your application needs to run.

Normally you use buildpacks to provide the language features for your app. That might be PHP, Ruby etc.. Under the hood Dokku creates a Docker container to run the application.

If you now need additional software, i.e. binaries your application calls, these are usually not there as those binaries like ffmpeg are not installed by default.

In this case you can use an additional buildpack to the rescue. This will inject the binary into the application container on deploy.

Finding a suitable buildpack

When you search for buildpack ffmpeg you will find some buildpacks like f.e. the one from shunkjikonishi and one by jonathanong. These are also the ones with the most stars (105 and 109 respectively). The good news: both work. The not so good news: The first one has an ancient (2013 or so) version of ffmpeg, the second one has a bleeding edge version.

Note that some or most of the buildpacks must not be the last one in your .buildpacks file or you need to use a Procfile. Otherwise the deployment will fail with something like '/app/Procfile' no such file or directory as the buildpacks do not merge the .release file created by other buildpacks. See here.

Install a specific version

I looked a bit further and stumbled across another one from kontentcore which provides a configuration variable to set the ffmpeg version.

Unfortunately the version of ffmpeg I wanted to use (4.1.4) was not available. I thought about building my own and there is also a build manual to bake your own. This whatsoever turned out to be too complicated to setup quickly as I don’t have an AWS account and did not intent to create one just for me this.

In the end a buildpack is just a couple of standardized shell scripts. I have written a fair amount of them. So build my own buildpack.

I forked the buildpack from jonathanong as it uses the static builds from John Van Sickle anyways. So the adaption work would just be to switch versions by an FFMPEG_VERSION configuration variable. The fork can be found here.

Note again that in your .buildpacks this buildpack should not be the last one!

Summary and lessons learned

Buildpacks are a nice and easy way to augment your application.

Regarding special software like ffmpeg there might be a lack of ready-made buildpacks but it was quite easy to adapt one to my needs. As written above these are only shell scripts and should be easily customizable (note that the shell is a Linux based shell so there might be differences in commands like sed and the likes).

The bigger issue here is that if you install something like ffmpeg while being stable might cause issues later on. If a process is started and crashes, or worse goes wild, the whole application will be affected by it as it all runs in one Docker container.

Photo by Donovan Silva on Unsplash