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

Decreasing Docker image size by cleaning yum cache? #65

Closed
JulianHn opened this issue Jun 12, 2022 · 4 comments
Closed

Decreasing Docker image size by cleaning yum cache? #65

JulianHn opened this issue Jun 12, 2022 · 4 comments

Comments

@JulianHn
Copy link
Contributor

Hey,

inspired by the discussion here ome/omero-web-docker#67, I checked the Dockerfile for the OMERO.server Docker as well and it is possible to decrease the image size significantly by cleaning the yum caches after installing.

Docker diff:

--- a/Dockerfile
+++ b/Dockerfile
@@ -9,15 +9,20 @@ WORKDIR /opt/setup
 ADD playbook.yml requirements.yml /opt/setup/
 
 RUN yum -y install epel-release \
     && yum -y install ansible sudo ca-certificates \
-    && ansible-galaxy install -p /opt/setup/roles -r requirements.yml
+    && ansible-galaxy install -p /opt/setup/roles -r requirements.yml \
+    && yum -y clean all \
+    && rm -fr /var/cache
 
 ARG OMERO_VERSION=5.6.4
 ARG OMEGO_ADDITIONAL_ARGS=
 ENV OMERODIR=/opt/omero/server/OMERO.server/
 RUN ansible-playbook playbook.yml \
     -e omero_server_release=$OMERO_VERSION \
-    -e omero_server_omego_additional_args="$OMEGO_ADDITIONAL_ARGS"
+    -e omero_server_omego_additional_args="$OMEGO_ADDITIONAL_ARGS" \
+    && yum -y clean all \
+    && rm -fr /var/cache
 
 RUN curl -L -o /usr/local/bin/dumb-init \
     https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 && \

This leads to the following image sizes (updated has an additional yum update -y in the first RUN command.

| Options | Image Size |
| Current | 2.34 GB |
| Cleaned | 1.63 GB |
| Cleaned & Update | 1.73 GB |

This would be a 700MB or almost 30% decrease in image size or roughly 25% if the base CentOS image is updated during the build.

// Julian

@joshmoore
Copy link
Member

👍 @JulianHn: thanks for looking into that. Do you want to open a PR?

@JulianHn
Copy link
Contributor Author

@joshmoore Sure. What is the verdict on performing a yum update?

@JulianHn JulianHn mentioned this issue Jun 21, 2022
@joshmoore
Copy link
Member

As in ome/omero-web-docker#67 (comment), I'd tend to favor an automated rebuild in order to keep the relationship to upstream images rather than creating our open "custom" centos distribution. Open to other opinions (including the opinion that it will take to long to get the rebuild in place and that we should therefore use yum update as a stop-gap)

@JulianHn
Copy link
Contributor Author

Implemented into the codebase with #69.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants