vindarel / lisp-journey

Discovering the Common Lisp ecosystem. https://lisp-journey.gitlab.io/
2 stars 0 forks source link

blog/lisp-for-the-web-build-standalone-binaries-foreign-libraries-templates-static-assets/ #33

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Lisp for the web: building one standalone binary with foreign libraries, templates and static assets - Lisp journey

In our previous entry, we saw how to deploy our web application with Systemd, either from sources or with a binary. Now we’ll speak more about this building process to produce one binary that contains everything for our web app. We’ll tackle 3 issues: ship foreign libraries alongside your binary, such as libreadline.so or libsqlite3.so, include your Djula templates into your binary, serve static files from your binary, without reading the filesystem, and we’ll see my Gitlab CI recipe.

https://lisp-journey.gitlab.io/blog/lisp-for-the-web-build-standalone-binaries-foreign-libraries-templates-static-assets/

vindarel commented 1 year ago

A good comment received on Discord:


There seems to be a problem with serving static files - you read the file as string, and that might be a problem for binary files. Maybe using something like

for content = (alexandria:read-file-into-byte-vector (merge-pathnames file static-directory)) 

would be better.

In your case it's just two text files, but it might change in the future, i.e. with WebAssembly additionally, the string has to be encoded/decoded into octets, and might occupy more memory (up to 4 times in sbcl?), while the byte-vector has no extra processing.

vindarel commented 1 year ago

Comments on reddit.


by @tdrhq (of Screenshotbot):

The only thing that bothers me here is updating *features* using --eval. I've found that to be error prone, because asdf doesn't know it needs to rebuild the files that use the feature. I suppose if the build is always done in GitLab, it doesn't matter, but at some point you'll be testing out that flow locally and it'll lead to hard-to-debug bugs.


which is spot-on because I did observe a weird, non-reproducible behaviour.

=> instead of using the *features* list, use a global parameter.