Hacker News new | past | comments | ask | show | jobs | submit login

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




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!


Might be possible to extend asmhttpd to serve gzipped files directly (possibly breaking compliance with rfcs by forcing compression)? Ie send index.html.gz?




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: