AutoGPT icon indicating copy to clipboard operation
AutoGPT copied to clipboard

Dockerfile: reduce layer bloat

Open DrMurx opened this issue 2 years ago • 5 comments

Background

The current Dockerfile generates a large amount of unneeded layers containing copies of the APT cache at build time.

Changes

A GPT model advised to modify the Dockerfile like this. ;-)

Documentation

This is what the GPT model had to say about its changes:

In this new version, we've merged all installation steps in a single RUN command. This way, we can reduce the number of layers in the image and avoid bloating it unnecessarily. We first install all the dependencies except Chromium and Firefox-ESR. After that, we add the Google repository key and repository to the sources list, and then we update the package lists again and install Chromium and Firefox-ESR. We've added a clean step to remove the apt cache and other unused files, reducing the size of the resulting layer.

Test Plan

PR Quality Checklist

  • [x] My pull request is atomic and focuses on a single change.
  • [ ] n/a I have thoroughly tested my changes with multiple different prompts.
  • [x] I have considered potential risks and mitigations for my changes.
  • [ ] n/a I have documented my changes clearly and comprehensively.
  • [x] I have not snuck in any "extra" small tweaks changes

DrMurx avatar Apr 21 '23 15:04 DrMurx

Anecdotally our Docker Build CI task took twice as long on this PR. Would want to check that before committing.

richbeales avatar Apr 21 '23 18:04 richbeales

Anecdotally our Docker Build CI task took twice as long on this PR. Would want to check that before committing.

@richbeales That may very well be and it heavily depends on how you've organized your builds.

Fewer container image layers also means fewer opportunities for the build cache. I would argue that layer caching is most beneficial during development where you execute docker build frequently in your local environment, but a CI build job should always start clean (ie docker build --no-cache) to avoid stale dependencies.

DrMurx avatar Apr 21 '23 18:04 DrMurx

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

github-actions[bot] avatar Apr 24 '23 13:04 github-actions[bot]

This is a mass message from the AutoGPT core team. Our apologies for the ongoing delay in processing PRs. This is because we are re-architecting the AutoGPT core!

For more details (and for infor on joining our Discord), please refer to: https://github.com/Significant-Gravitas/Auto-GPT/wiki/Architecting

p-i- avatar May 05 '23 00:05 p-i-

would also be interested in less bloat :+1:

Boostrix avatar May 07 '23 10:05 Boostrix

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Jun 7, 2023 0:54am

vercel[bot] avatar Jun 07 '23 00:06 vercel[bot]

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

github-actions[bot] avatar Jun 07 '23 00:06 github-actions[bot]

Codecov Report

Patch and project coverage have no change.

Comparison is base (fdc6e12) 69.71% compared to head (f94bf5c) 69.71%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2821   +/-   ##
=======================================
  Coverage   69.71%   69.71%           
=======================================
  Files          72       72           
  Lines        3560     3560           
  Branches      569      569           
=======================================
  Hits         2482     2482           
  Misses        889      889           
  Partials      189      189           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Jun 07 '23 00:06 codecov[bot]

This is saving ~18MB overall.. just over 1% of the release image :')

Pwuts avatar Jun 07 '23 01:06 Pwuts