ziglang/docker-zig

reduce image size

tiehuis opened this issue · 2 comments

The image is fairly large and could probably be cleaned up a fair amount. llvm likely takes a large portion however and I'm unsure the savings we could get there.

Look into squashing the image at least.

$ docker history zig
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
b7ecf9676f95        25 minutes ago      /bin/sh -c #(nop)  CMD ["zig"]                  0B                  
025b1226fc2f        25 minutes ago      /bin/sh -c #(nop) WORKDIR /z                    0B                  
57791a4676af        25 minutes ago      /bin/sh -c make install                         105MB               
7866fd9738d6        25 minutes ago      /bin/sh -c make                                 523MB               
ee088ff9e271        29 minutes ago      /bin/sh -c cmake ..                       ...   633kB               
2be9e3ea72ca        29 minutes ago      /bin/sh -c #(nop) WORKDIR /app/zig/build        0B                  
162e772ade7a        29 minutes ago      /bin/sh -c git clone https://github.com/zi...   36MB                
71fdcd636e09        29 minutes ago      /bin/sh -c #(nop) WORKDIR /app                  0B                  
e4f77851af78        29 minutes ago      /bin/sh -c apt-get update                 ...   1.32GB              
de0eb5c10ada        6 weeks ago         /bin/sh -c #(nop)  CMD ["bash"]                 0B                  
<missing>           6 weeks ago         /bin/sh -c #(nop) ADD file:366ed17a0f83cce...   107MB               

I think we should build llvm from source in release mode, compile zig against it statically, then delete all the filesystem stuff that isn't needed. the final result should be something like 80 MB.

See if that's better. I tried these changes and got an image that is about 200 MB and pushed it to andrewrk/zig.