Uploaded image for project: 'Nuxeo Drive '
  1. Nuxeo Drive
  2. NXDRIVE-2271

[GNU/Linux] Reduce the docker image size

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.4.5
    • Component/s: Packaging / Build

      Description

      Connecting to the image using that command:

      $ docker run --user root:root -it docker-private.packages.nuxeo.com/nuxeo-drive-build:py-3.7.7 bash
      

      Clean-up 1

      $ du -sh /opt/deploy-dir/.pyenv/versions/3.7.7/lib/python3.7/* | sort -rh
      61M	/opt/deploy-dir/.pyenv/versions/3.7.7/lib/python3.7/test
      23M	/opt/deploy-dir/.pyenv/versions/3.7.7/lib/python3.7/config-3.7m-x86_64-linux-gnu
      13M	/opt/deploy-dir/.pyenv/versions/3.7.7/lib/python3.7/site-packages
      # ...
      

      The first folder is amazingly huge. It contains only CPython-specific test files and we should remove them.

      => Win 61 MB.

      Clean-up 2

      $ du -sh /user/lib/* | sort -rh
      103M	lib/locale
      13M	lib/udev
      9.2M	lib/systemd
      # ...
      
      $ cd lib/locale
      $ du -sh * | sort -rh
      102M	locale-archive.tmpl
      1.6M	locale-archive
      

      So many locales for nothing, let's remove all unwanted:

      $ cd /usr/lib/locale
      $ build-locale-archive
      $ localedef --list-archive | grep -v 'en_US.utf8' | xargs localedef --delete-from-archive
      $ /bin/cp -f locale-archive locale-archive.tmpl
      $ build-locale-archive
      $ du -sh * | sort -rh
      1.5M	locale-archive
      0	locale-archive.tmpl
      $ localedef --list-archive
      en_US.utf8
      

      => Win 100 MB.

      Clean-up 3

      Remove unused requirements installed at the beginning:

      $ yum erase -y git-core && yum clean all
      Loaded plugins: fastestmirror
      Resolving Dependencies
      --> Running transaction check
      ---> Package git.x86_64 0:1.8.3.1-23.el7_8 will be erased
      --> Processing Dependency: git = 1.8.3.1-23.el7_8 for package: perl-Git-1.8.3.1-23.el7_8.noarch
      --> Running transaction check
      ---> Package perl-Git.noarch 0:1.8.3.1-23.el7_8 will be erased
      --> Finished Dependency Resolution
      
      Dependencies Resolved
      
      ===========================================================================================================================================
       Package                        Arch                         Version                                  Repository                      Size
      ===========================================================================================================================================
      Removing:
       git                            x86_64                       1.8.3.1-23.el7_8                         @updates                        22 M
      Removing for dependencies:
       perl-Git                       noarch                       1.8.3.1-23.el7_8                         @updates                        57 k
      
      Transaction Summary
      ===========================================================================================================================================
      Remove  1 Package (+1 Dependent package)
      
      Installed size: 22 M
      Downloading packages:
      Running transaction check
      Running transaction test
      Transaction test succeeded
      Running transaction
        Erasing    : perl-Git-1.8.3.1-23.el7_8.noarch                                                                                        1/2 
        Erasing    : git-1.8.3.1-23.el7_8.x86_64                                                                                             2/2 
        Verifying  : git-1.8.3.1-23.el7_8.x86_64                                                                                             1/2 
        Verifying  : perl-Git-1.8.3.1-23.el7_8.noarch                                                                                        2/2 
      
      Removed:
        git.x86_64 0:1.8.3.1-23.el7_8                                                                                                            
      
      Dependency Removed:
        perl-Git.noarch 0:1.8.3.1-23.el7_8                                                                                                       
      
      Complete!
      Loaded plugins: fastestmirror
      Cleaning repos: base extras updates
      Cleaning up everything
      

      => Win 22 MB.

      Total size reduction: 183 MB. Not bad.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h

                  PagerDuty

                  Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.