Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving cleanup to dramatically reduce image size #94

Closed
roelvanhintum opened this issue Apr 22, 2024 · 5 comments
Closed

Moving cleanup to dramatically reduce image size #94

roelvanhintum opened this issue Apr 22, 2024 · 5 comments
Labels
bug Something isn't working Craft Docker Images Linear sync

Comments

@roelvanhintum
Copy link

Description

Moving cleanup to the same RUN as install and build reduces image size. Right now the cleanup is a separate RUN command in the docker files. At the end of a RUN command a new layer is created. Doing cleanup in a later layer does nothing for the resulting docker image.

Steps to reproduce

  1. Build current docker image
  2. Move cleanup command (for example https://github.com/craftcms/docker/blob/main/8.2/Dockerfile#L116) to the same step where the installs are performed.
  3. Optionally move MozJPEG to a separate build stage
  4. Build image again to compare to previous one

Additional info

  • craftcms/cms version: -
  • PHP version: -
  • Database driver & version: -
  • Plugins & versions: -
@roelvanhintum roelvanhintum added bug Something isn't working Craft Docker Images Linear sync labels Apr 22, 2024
Copy link

linear bot commented Apr 22, 2024

@timkelty
Copy link
Collaborator

@roelvanhintum Please see #93

@roelvanhintum
Copy link
Author

@timkelty Thanks! Regardless of that, it would still be a huge improvement. Maybe this is also the case in the new images?
We made our own version, based upon the images here but without imagick, resulting in 197MB vs craftcms/nginx:8.2 931MB

@timkelty
Copy link
Collaborator

timkelty commented Apr 22, 2024

@roelvanhintum agreed! We're happy to accept a PR, or if we get the time before we officially read-only this repo, it seems worthwhile.

I'm going to leave this open for now.

Pinging @jasonmccallister to make any cleanup is happening in the appropriate layers in the new images.

@timkelty timkelty reopened this Apr 22, 2024
@jawys
Copy link
Contributor

jawys commented Apr 22, 2024

@roelvanhintum @timkelty see #41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Craft Docker Images Linear sync
Projects
None yet
Development

No branches or pull requests

3 participants