Closed SethFalco closed 4 years ago
Thanks for the PR @SethiPandi . If you wish to be added as a contributor to https://accumulo.apache.org/people/ , please open a pull request to add yourself at https://github.com/apache/accumulo-website/edit/main/pages/people.md and leave a reference to apache/accumulo-docker#14
in your commit log.
If you intend to be a regular contributor to Accumulo projects, please consider subscribing to our developer mailing list (https://accumulo.apache.org/contact-us/) and introducing yourself. :smiley_cat:
The Dockerfile for this had a few issues which bloated the size of the image, and how many layers it had.
This does not follow all practices from the Dockerfile Best Practices, but just a few easy adjustments that should be risk free from breaking anything.
In an ideal world, this should be a multistage build that separate the build from the runtime, so that the final image doesn't include any development tools like JDK/gcc or utilities like wget; reducing the size of the image further and reducing the attack surface from third-parties.
The original image before this PR was 2.91 GB, it's now 1.96 GB.
Minimizing Layers
Every instance of
RUN
,ADD
, andCOPY
creates a newlayer
in a Docker image and creates a new intermediate image. For this reason, it's best to minimize the number of these in a Dockerfile. This will both speed up the build process of the image itself, but also reduce the size of it.RUN
statements into one..properties
files into a directory so that the contents of the directory can be moved in a singleADD
statement instead of separate ones.See: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#minimize-the-number-of-layers
Ignoring Files
This one very minor for a repo like this, but it can speed up the build and reduce the size to exclude files from the build context if they're not needed there. Due to the size of the repo, the difference this makes is negligible; but I added one anyway to exclude what I think isn't required.
See: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#exclude-with-dockerignore