Faster builds with Docker cache and BuildKit #5
llaville
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What you'll learn ?
Audience
Developers, DevOps engineers, and Contributors with PHP and Docker skill.
Step 1 - explains the Docker caching mechanisms
The first alpha version of prototype
uses benefits of BuildKit
to speed up make of Docker Images.
Of course to use it you require at least Docker 19.03 (check it with command
docker --version
)The second alpha version of prototype will come with more extensions (+40) and tools (+5) supported,
but also a speed optimization in building process.
Before to see why it's possible, we must learn how Docker Layer Caching works.
Docker caches each layer as an image is built, and each layer will only be re-built
if it or the layer above it has changed since the last build.
So, you can significantly speed up builds with Docker cache if you don't change layer order.
Step 2 - explains alpha2 PHP changes
Once a new extension is added, the new corresponding layer (
RUN install-php-extensions <ext_name>
) is appended to command stackrather than inserting in alphabetic order.
In
src/Collection/Tools.php
, we've extracted ordering collection process in new public methodsortByName()
.The alphabetic order is only applied on
list:tools
,list:extensions
, andupdate:readme
commands,while
build:dockerfile
command use only the Symfony Finder order results, return byload()
method.See commit 33967d7 for details of change.
Step 3 - learn more about faster builds
Other tips to use cache as much as possible (already implemented since 1.0 alpha1) are explained very well in following articles :
Beta Was this translation helpful? Give feedback.
All reactions