Test Flutter on Drone CI

This post is specific to Drone CI, but is probably easily adoptable to other CI systems, like Gitlab.

Flutter is UI library based on Dart to create beautiful, natively compiled applications for mobile. Web and desktop targets are also in the works.

Recently I’ve been playing around with Flutter and Dart. As a backend engineer I have to say I quite like it. Dart is a breeze to work with, the static typing helps a lot. Flutter itself offers a react-like way of structuring your app, but it runs natively on Android and iOS. At Kabisa we’re in the process of adopting Flutter as our go-to solution for cross platform mobile apps.

Anyway, one of the first things I do is hook a new project up with my CI, currently Drone CI. I started looking for
an already published docker image that contains the latest flutter-stable installation. I soon found cirruslabs/docker-images-flutter,
but ran into an permission error. Turns out [I’m not the only one][cl-issues], but with a few simple steps you can test your flutter app with this image on Drone CI without issue.

The magic is the sudo chown -R cirrus:cirrus .. The flutter docker images are based on Cirrus Labs’ android SDK images, which runs
commands as the cirrus user. This will change permissions and the flutter commands can now run without issue.

Any next steps in your pipeline will encounter files owned by cirrus. Since most drone plugins and images run as root anyway, this is not much of and issue. You could add another command to the snippet above to reset permissions back to root.

Note that I’m using cirrusci/flutter:stable. They’ve also got images available for beta and dev, just use the appropriate tag.

My site is free of ads and trackers. I record privacy-respecting usage statistics with
Fathom.