Skip to content

Add slim variant for docker image codercom/code-server #2488

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
nhooyr opened this issue Dec 18, 2020 · 3 comments
Closed

Add slim variant for docker image codercom/code-server #2488

nhooyr opened this issue Dec 18, 2020 · 3 comments
Labels
feature New user visible feature
Milestone

Comments

@nhooyr
Copy link
Contributor

nhooyr commented Dec 18, 2020

See #2463
See #2461
See #2459
See #4112

cc @jylenhof

@nhooyr nhooyr added the feature New user visible feature label Dec 18, 2020
@nhooyr nhooyr added this to the v3.8.1 milestone Dec 18, 2020
@jylenhof
Copy link

Ok will try to explain a little bit problems with the debian package in your layer.... There are two problem here !

First step, get your docker image provided on docker hub :
"docker pull codercom/code-server"
Install a nice tool to see layer and what takes place in your image...
"wget https://github.com/wagoodman/dive/releases/download/v0.9.2/dive_0.9.2_linux_amd64.deb"
"dpkg -i dive_0.9.2_linux_amd64.deb"

Launch the tool on your docker image by using :
dive codercom/code-server

┃ ● Layers ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ Current Layer Contents ├─────────────────────────────────────
Cmp Size Command Permission UID:GID Size Filetree
114 MB FROM b6f8627eb28b093 drwxr-xr-x 0:0 5.7 MB ├── bin
230 MB apt-get update && apt-get install -y curl -rwxr-xr-x 0:0 1.2 MB │ ├── bash
3.0 MB sed -i "s/# en_US.UTF-8/en_US.UTF-8/" /etc/locale.g -rwxr-xr-x 0:0 44 kB │ ├── cat
1.3 kB chsh -s /bin/bash -rwxr-xr-x 0:0 64 kB │ ├── chgrp
335 kB adduser --gecos '' --disabled-password coder && e -rwxr-xr-x 0:0 64 kB │ ├── chmod
4.4 MB ARCH="$(dpkg --print-architecture)" && curl -fs -rwxr-xr-x 0:0 72 kB │ ├── chown
190 MB #(nop) COPY multi:681f78c08663aff8725f4c2657043e18e -rwxr-xr-x 0:0 147 kB │ ├── cp
673 B #(nop) COPY file:e769accb89a88f6129d4121c1ecef183bc -rwxr-xr-x 0:0 122 kB │ ├── dash
336 MB dpkg -i /tmp/code-server*$(dpkg --print-architectur -rwxr-xr-x 0:0 109 kB │ ├── date
-rwxr-xr-x 0:0 77 kB │ ├── dd
│ Layer Details ├────────────────────────────────────────────── -rwxr-xr-x 0:0 94 kB │ ├── df
-rwxr-xr-x 0:0 139 kB │ ├── dir
Tags: (unavailable) -rwxr-xr-x 0:0 84 kB │ ├── dmesg
Id: b6f8627eb28b093db69daf750e60842548e1626b7bf11a98159ffe3 -rwxrwxrwx 0:0 0 B │ ├── dnsdomainname → host
1fc19f72f -rwxrwxrwx 0:0 0 B │ ├── domainname → hostnam
Digest: sha256:114ca5b7280f3b49e94a67659890aadde83d58a8bde0d902 -rwxr-xr-x 0:0 40 kB │ ├── echo
0b2bc8c902c3b9de -rwxr-xr-x 0:0 28 B │ ├── egrep
Command: -rwxr-xr-x 0:0 35 kB │ ├── false
#(nop) ADD file:9a4fd72d749f4a791e75e0f6fc6028d0771e3381b6d84a8 -rwxr-xr-x 0:0 28 B │ ├── fgrep
d0b07a4887bc7c641 in / -rwxr-xr-x 0:0 69 kB │ ├── findmnt
-rwxr-xr-x 0:0 199 kB │ ├── grep
│ Image Details ├────────────────────────────────────────────── -rwxr-xr-x 0:0 2.3 kB │ ├── gunzip
-rwxr-xr-x 0:0 6.4 kB │ ├── gzexe
-rwxr-xr-x 0:0 98 kB │ ├── gzip
Total Image size: 877 MB -rwxr-xr-x 0:0 27 kB │ ├── hostname
Potential wasted space: 194 MB -rwxr-xr-x 0:0 584 kB │ ├── ip
Image efficiency score: 78 % -rwxr-xr-x 0:0 69 kB │ ├── ln
-rwxr-xr-x 0:0 57 kB │ ├── login
Count Total Space Path -rwxr-xr-x 0:0 139 kB │ ├── ls
2 95 MB /tmp/code-server_3.7.4_amd64.deb -rwxr-xr-x 0:0 109 kB │ ├── lsblk
2 94 MB /tmp/code-server_3.7.4_arm64.deb -rwxr-xr-x 0:0 89 kB │ ├── mkdir

Here's is....
You have both the arm64 package and the amd64 package in your layer for the amd64 image file because you probably compile all different version before copying using "COPY release-packages/code-server*.deb /tmp/" in your Dockerfile
You don't see directly this problem because you remove both package using the line "RUN dpkg -i /tmp/code-server*$(dpkg --print-architecture).deb && rm /tmp/code-server*.deb" in your Dockerfile

So this arm deb file is a pure 95 MB waste of size on your final docker file because you don't ever install it because you correctly use "--print-architecture" to install the only good one.

To resolve this first problem you probably only have to specify a better wildcard when you copy the deb file.... This one should be quite easy to solve

Second problem is more difficult to resolve because it probably involves to change your CI pipeline to make the deb file available somewhere on the internet (github is a solution as I do) and make all the get, installation and remove of the deb package in one line.... To save another 95 MB in your final docker image

@nhooyr
Copy link
Contributor Author

nhooyr commented Dec 18, 2020

Second problem is more difficult to resolve because it probably involves to change your CI pipeline to make the deb file available somewhere on the internet (github is a solution as I do) and make all the get, installation and remove of the deb package in one line.... To save another 95 MB in your final docker image

Ah thank you for clarifying! That makes perfect sense.

I'll take care of that as part of this issue as it's going to be required to make the slim image truly slim :)

@nhooyr nhooyr removed this from the v3.8.1 milestone Feb 5, 2021
@jsjoeio jsjoeio added this to the Backlog milestone Apr 29, 2021
@stale
Copy link

stale bot commented Mar 7, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days.

@stale stale bot added the stale label Mar 7, 2022
@stale stale bot closed this as completed Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New user visible feature
Projects
None yet
Development

No branches or pull requests

3 participants