www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Running a website using a 1.3MB self-contained executable

reply Andrea Fontana <nospam example.com> writes:
I’ve published an example showcasing how to use serverino to 
serve a web server that generates QR codes, without any external 
dependencies (not even glibc) and without reading or writing any 
files to disk.

It’s a single file, 1.3MB in size, which you can try by 
downloading it from the project’s GitHub page: 
https://github.com/trikko/serverino-demo/ or by checking the 
result at https://test.andreafontana.it.

The file can run inside a Docker scratch container or completely 
isolated from the rest of the system with bwrap, and it works 
perfectly!

Using upx/gzexe size goes down to <500KB

If you want to try serverino:

```


   █▀▀▀▀▀█ █▄▀  ███ ▄█▄  █▀▀▀▀▀█
   █ ███ █ ▀█▄▄█▀█▄▄▄ █▄ █ ███ █
   █ ▀▀▀ █ ▀▀▀▀ █▄▀  █▀  █ ▀▀▀ █
   ▀▀▀▀▀▀▀ ▀ ▀▄▀ █▄█ ▀ █ ▀▀▀▀▀▀▀
   █▄▄█▀█▀▀██▄ ▄▀█▄▀█▄█▀█ ▄█
██▀
    ▄▀▀ ▄▀  ▀▀ █ ██ ▄  █▄▄█▀▄▀ ▄
    ▄ ██ ▀██▄███▀▀▄█▄█▀  ██▄▄▄▄█
   ▄▀▄▄ ▄▀▄▄▀█▀▄▄█▀▄▀ █▀▀▀▄█ █
█
   █▄▄ █▀▀▄ ▄ ▄▀  ▄ ▄ █▀▀  ▄▀▄▄
   ██ ▄▄ ▀▀▄▀▄███▀█▀ ▀█  ▄ ▀█▄ ▀
   ▀▀▀▀ ▀▀▀███▄▀█ █ ▀▄ █▀▀▀██▀▀
   █▀▀▀▀▀█ █▀ ▄▄█ ▀▀█ ██ ▀ █▀ ▄
   █ ███ █ █  ███▄██  ▀▀█▀▀▀▀ ▀█
   █ ▀▀▀ █  ▄ ▀▀▀ █▀▀█ ▀▀▄█▀▄█▀█
   ▀▀▀▀▀▀▀ ▀    ▀▀▀▀  ▀▀ ▀ ▀

```

Andrea Fontana
Jan 19
parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Sunday, 19 January 2025 at 21:17:29 UTC, Andrea Fontana wrote:
 I’ve published an example showcasing how to use serverino to 
 serve a web server that generates QR codes, without any 
 external dependencies (not even glibc) and without reading or 
 writing any files to disk.
Awesome. I tried this many times but due to (transitive) dependencies on glibc always had to give up (e.g. gethostname). Switching to musl often failed as well because it isn't as supported as glibc in druntime.
Jan 20
next sibling parent Andrea Fontana <nospam example.com> writes:
On Monday, 20 January 2025 at 08:55:43 UTC, Sebastiaan Koppe 
wrote:
 On Sunday, 19 January 2025 at 21:17:29 UTC, Andrea Fontana 
 wrote:
 I’ve published an example showcasing how to use serverino to 
 serve a web server that generates QR codes, without any 
 external dependencies (not even glibc) and without reading or 
 writing any files to disk.
Awesome. I tried this many times but due to (transitive) dependencies on glibc always had to give up (e.g. gethostname). Switching to musl often failed as well because it isn't as supported as glibc in druntime.
In this case musl worked! You can see the workflow here: https://github.com/trikko/serverino-demo/blob/main/.github/workflows/main.yml Andrea
Jan 20
prev sibling parent Johan <j j.nl> writes:
On Monday, 20 January 2025 at 08:55:43 UTC, Sebastiaan Koppe 
wrote:
 On Sunday, 19 January 2025 at 21:17:29 UTC, Andrea Fontana 
 wrote:
 I’ve published an example showcasing how to use serverino to 
 serve a web server that generates QR codes, without any 
 external dependencies (not even glibc) and without reading or 
 writing any files to disk.
Awesome. I tried this many times but due to (transitive) dependencies on glibc always had to give up (e.g. gethostname). Switching to musl often failed as well because it isn't as supported as glibc in druntime.
LDC 1.39 and up has improved support of musl, including CI testing on Alpine. Pretty soon there will also be alpine-musl release packages of LDC on Github: https://github.com/ldc-developers/ldc/pull/4826 thanks to kinke's work. cheers, Johan
Jan 20