Starting v0.1.64, flyctl uses BuildKit’s native Go client for building container images faster.
BuildKit is Docker’s new image building mechanism. While flyctl has been using BuildKit already, it used BuildKit through Docker Engine’s ImageCreate API which missed one key feature: sending files on demand.
The ImageCreate API is a “push” model. To build a container image, Docker clients need to make a tarball upfront and push that to the server to start building the image. The tarball contains your local directory and is called “build context”. This model allows Docker clients to use Docker Engine servers in different hosts. At Fly.io, we are provisioning Docker Engine servers in our infrastructure to build container images.
However, sending a tarball upfront is slow and wasteful. You may not need all files in the local directory. Meticulously blocklisting files by writing .dockerignore is of course possible, but do you really want to do that?
BuildKit is solving the problem by being a “pull” model. BuildKit clients start a small gRPC server to serve local files and the server pulls files on-demand. Supercharged Docker Build with BuildKit (2018) talks about the difference along with other interesting features.
Docker itself made BuildKit default and using Buildkit’s native Go client via Buildx for a while. So this update should make flyctl behave more like Docker and reduce surprises.
Enjoy!