Skip to content

Simple Web application to illustrate statically linked nim application built as a docker image <6MB

Notifications You must be signed in to change notification settings

btbytes/simplestatapp

Repository files navigation

Simple Static Application

This is an illustrative example of how to build statically linked nim application that produce very small single exeuctables (in the order of few MBs).

This application uses Nim Language, which compiles down to C, and subsequently to a small, performant, standalone binary.

This simple web application uses the Prologue web framework to present the table at the bottom of the page, which is data rendered from reading the students.db SQLite database, which has a single table "users" with 10 dummy student records.

The table is the result of querying the sqlite database on every request and rendering it as an HTML table.

In order to present this page, the following dependencies were statically linked:

  1. SQLite3
  2. PCRE

and the following nim libraries were also compiled in:

  1. prologue (and all it's dependencies)
  2. db_connector
  3. markdown

The resulting standalone docker image is a mere 5.64mb all dependencies included.

$ docker image ls simplestatapp
REPOSITORY      TAG       IMAGE ID       CREATED         SIZE
simplestatapp   latest    9d3dc3a9cc58   3 minutes ago   5.64MB

You can see also see the image size during this fly.io deployment.

fly.io deployment image size

The code for this application is at https://github.com/btbytes/simplestatapp/, and hosted on fly.io - https://simplestatapp.fly.dev/

If you are curious about all the things that get added, built, and copied, you can inspect the Dockerfile or take a look at the actual docker build with github actions.

And without much ado, the table:

About

Simple Web application to illustrate statically linked nim application built as a docker image <6MB

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published