Uploaded image for project: 'Policy Framework'
  1. Policy Framework
  2. POLICY-4208

Reduce size of docker images


    • Icon: Story Story
    • Resolution: Done
    • Icon: Medium Medium
    • Kohn Release
    • None
    • all

      Some of the Policy Framework docker images are much larger than needed.

      As an example, by some simple changes, e.g. avoiding duplicate copies of files and avoiding running `chown` as a separate command where possible (docker's COPY and ADD command can take a chown parameter), the image size for policy-api was reduced from 956MB to 259MB (73% reduction). Based on analyzing the layers, this appears to be the smallest possible.

      There are a few causes including:

      • For some images, maven copies all jar dependencies into a tarball. Following Spring Boot migration, spring-boot-maven-plugin creates executable jars already containing all dependencies - thus data is being duplicated.
      • Many images copy files into the image by creating a tarball, which creates 3 layers in the image: copying the tarball to the image (1st layer), extracting the archive and deleting the tarball (2nd layer), chown'ing the extracted files (3rd layer). This can be avoided e.g. by using multi-stage docker build.

        There are no Sub-Tasks for this issue.

            danielhanrahan Daniel Hanrahan
            danielhanrahan Daniel Hanrahan
            0 Vote for this issue
            1 Start watching this issue