20 December 2019 - Simple Dockerfile Performance Improvements (Part 1)
As a developer, I find that one of the easiest ways to ship an application is to create a Docker image via a custom Dockerfile in order for it to be deployed usually on AWS/Azure/Oracle cloud Kuberenetes (AKS, EKS, OKE). In recent times I’ve spent some time looking into the docker image created and attempted to find ways to shrink the final image size and also make the build quicker by caching docker image layers, this post is Part 1 of my approaches and also the final outcomes. This particular Dockerfile builds an Oracle JET UI Application.
TL;DR:- Ordering your commands in terms of slowly-changing outputs to more frequently increasing output has a huge impact on build time, explicitly specifying files to copy instead of copying everything results in image size reduction and finally using ADD for local tar archives means Docker will automatically unpack the archive for you, no more manual unpacking! The above might sound like common sense but they’re often overlooked, even in production ready applications.