News for hackers. Stuff that matters.
Re:Tiny Container Challenge: Building a 6kB Containerized HT... by friseurtermin on Thursday April 22, 2021 @06:00AM (#26900844)
I love blog posts like these: they don't go after real-world problems directly but rather explore what's even possible.

paulfurtado in this comment section mentioned UPX[0] as a way to get binaries even smaller. Funnily enough UPX even managed to decrease the size of the asmttpd web server for me:

    ### build stage ###
    FROM ubuntu:18.04 as builder
    RUN apt update
    RUN apt install -y make yasm as31 nasm binutils git
    RUN git clone https://github.com/nemasu/asmttpd.git asmttpd
    RUN mv asmttpd/* .
    RUN rm -rd asmttpd
    RUN make release
    
    # i have the upx binary on my machine in this case
    COPY ./upx-3.96-amd64_linux/upx upx
    RUN ./upx --brute asmttpd
    
    ### run stage ###
    FROM scratch
    COPY --from=builder /asmttpd /asmttpd
    COPY ./index.html /web_root/index.html
    CMD ["/asmttpd", "/web_root", "8080"]
With a 4 byte index.html my total image size is now 5.3kB!

[0]: https://github.com/upx/upx

Re:Tiny Container Challenge: Building a 6kB Containerized HT... by spalas on Thursday April 22, 2021 @10:43AM (#26903314)
Hi, author here!

Thanks for the kind words. I didn't know about UPX.

I should add an update to the end with this trick!

Re:Tiny Container Challenge: Building a 6kB Containerized HT... by e12e on Thursday April 22, 2021 @07:03AM (#26901340)
Might be possible to extend asmhttpd to serve gzipped files directly (possibly breaking compliance with rfcs by forcing compression)? Ie send index.html.gz?