mindrunner / docker-android-sdk

GNU General Public License v3.0
277 stars 169 forks source link

Implement docker-slim for smaller images #47

Closed oxr463 closed 4 years ago

oxr463 commented 4 years ago

See: https://github.com/docker-slim/docker-slim

mindrunner commented 4 years ago

If I see this correctly, this would involve creating a proper build pipeline. Currently, I am building images with docker hub automated builds. I suppose, they do not support docker-slim.

Looks nice, btw. Did you build this images and compare the sizes?

oxr463 commented 4 years ago

Here is a good example from one of my projects,

Original size: 300 MiB Current size: 1.65 MiB

Source: https://gitlab.com/hexgearinc/ryzomcore-docker/-/blob/master/.gitlab-ci.yml

mindrunner commented 4 years ago

Awesome. Working on this right now. Probably replacing docker hub builds with gitlab pipelines by today.

oxr463 commented 4 years ago

Probably replacing docker hub builds with gitlab pipelines by today.

Love GitLab CI/CD! This will help with testing PRs too.

mindrunner commented 4 years ago

Yeap, and big performance boost compared to docker hub builds.

mindrunner commented 4 years ago

Alright, I reduced the image size from ~2.5GB to 40MB.... This looks suspicious to me. I doubt, we can compress the android SDK to that size. I tried to investigate and cannot even call ls in the container:

[le@y730]: ~/src/docker-android-sdk>$ docker run --rm -ti runmymind/docker-android-sdk:ubuntu-standalone-feature-pipeline bash
bash-4.4# ls
bash: ls: command not found

Is that expected? How can we make sure, we do not break things?

oxr463 commented 4 years ago

Is that expected? How can we make sure, we do not break things?

How did you build the image?

mindrunner commented 4 years ago

Pretty much analog to https://gitlab.com/hexgearinc/ryzomcore-docker/-/blob/master/.gitlab-ci.yml

  - docker build -t runmymind/docker-android-sdk:$TAG_PREFIX-$CI_COMMIT_REF_SLUG -f ${TAG_PREFIX/-/\//}/Dockerfile .
  - docker run -v /var/run/docker.sock:/var/run/docker.sock dslim/docker-slim build --http-probe=false runmymind/docker-android-sdk:$TAG_PREFIX-$CI_COMMIT_REF_SLUG
  - docker tag runmymind/docker-android-sdk.slim runmymind/docker-android-sdk:$TAG_PREFIX-$CI_COMMIT_REF_SLUG
  - docker push runmymind/docker-android-sdk:$TAG_PREFIX-$CI_COMMIT_REF_SLUG
mindrunner commented 4 years ago

If I try to use it in a CI, it does not work. It seems like almost everything from the image was erased. image

Is there an explanation what docker-slim is actually doing?

oxr463 commented 4 years ago

Check this out: https://github.com/docker-slim/docker-slim#minifying-command-line-tools, https://github.com/docker-slim/docker-slim#can-i-use-dockerslim-with-dockerized-command-line-tools. It strips out basically everything it can, so if you need a tool then you should declare it when you are building the slimmed down image.

mindrunner commented 4 years ago

Alright. Understand. This seem to be a long and error prone task. Especially, because many people use this image and I have no idea what they exactly do with it.

If you know what you are doing, I am happy to accept a PR for minified images. We can then gather feedback and see how it goes. But I think, I am going to offer both variants for a while then.

mindrunner commented 4 years ago

Closing due to lack of activity.