Skip to content

Docker image : layer not optimised #2463

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

Closed
jylenhof opened this issue Dec 14, 2020 · 1 comment
Closed

Docker image : layer not optimised #2463

jylenhof opened this issue Dec 14, 2020 · 1 comment

Comments

@jylenhof
Copy link

In your Dockerfile here "ci/release-image/Dockerfile", your layers are not optimised. You copy deb file with a COPY (perhaps you could even copy both the arm64 deb file and the amd64 deb file because your copy is using a very generic wilcard) in a layer and you install and delete file(s) in another layer. So the resulted image file is not optimised.

If you does'nt understand my explanation, another one here :
https://forums.docker.com/t/copy-a-file-that-doesnt-need-to-be-in-the-final-image/12627/4

To fix it in my build, I did this :

RUN cd /tmp && curl -L -O https://github.com/cdr/code-server/releases/download/
v3.7.4/code-server_3.7.4_amd64.deb && dpkg -i /tmp/code-server*$(dpkg --print-architecture).deb && rm /tmp/code-server*.deb

But this type of solution is not directly applicable I think because of your CI that intend to build package outside docker... And in your docker build step, install this package from the host which was just built.

The best solution is to made it available like I did and download with curl, but I think you need to modify some things on your scripts, I did'nt understand all the logic of your scripts...

Alternatives I don't like :

One which involve something else named buildkit to build the image, so don't like it :

https://docs.docker.com/engine/reference/builder/#buildkit

https://stackoverflow.com/questions/26306059/docker-in-dockerfile-copy-files-temporarily-but-not-for-final-image

Perhaps, there's also the possibility to use the "--squash" option during build, but does'nt really like it also.

So definitively something to fix, but don't know the good way for you... But the size of the deb file is so big, so you probably need to do something about it !

@nhooyr
Copy link
Contributor

nhooyr commented Dec 18, 2020

Hi @jylenhof

It's not clear to me what the problem you're referring to is.

Can you link to the specific lines you believe are causing the image to be bloated?

I've looked it over and I don't see any way to reasonably reduce it.

The .deb is big yes but it has to be in the image, as we have to run dpkg -i to install it. We can't just delete it afterwards.

Perhaps we can somehow remove the extra layers but I think a separate image is the best way forward.

I opened #2488

@nhooyr nhooyr closed this as completed Dec 18, 2020
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