Packaging a Jennifer app with Docker™

Jennifer

From a working directory to an image that is small, runs as an unprivileged user, carries no secrets, says when it is healthy and stops cleanly.

November 2026, by @mplx.
Based on Jennifer 0.26.0

Powered by Jennifer's Cantrip - Markdown into slide decks, https://github.com/jennifer-language/cantrip
1 / 18

The official interpreter images

TagBaseSizeUse
jennifer:0.26.0Debian™ trixie-slim168 MBdefault; shell, apt, jvc
jennifer:0.26.0-alpineAlpine60 MBsmall, still a build base
jennifer:0.26.0-staticdistroless51 MBno shell: runtime only
jennifer:devDebian~170 MBevery push to main

All under ghcr.io/jennifer-language/, for amd64 and arm64. ENTRYPOINT ["jennifer"], WORKDIR /work, a non-root user.

2 / 18

Try it before writing a Dockerfile

docker run --rm -p 127.0.0.1:8080:8080 -v "$PWD:/work:ro" \
    ghcr.io/jennifer-language/jennifer:0.26.0 run hello.j
web.run($app, "127.0.0.1:8080");  ->  curl: (56) Recv failure:
                                       Connection reset by peer
web.run($app, ":8080");           ->  hello, Ada

Inside a container, listen on all interfaces, not on loopback.

3 / 18

Keep the build context small: an allowlist

# .dockerignore: nothing is sent unless it is named here
*
!app.j
!addmember.j
!healthcheck.j
!src/
!public/
!docs/
!grimoire.toml
**/*_test.j
4 / 18

What actually reached the build

$ ls -A
addmember.j   Dockerfile     .env           healthcheck.j  src
app.j         .dockerignore  .env.example   public
compose.yaml  docs           grimoire.toml  secrets

# the context, as COPY . /ctx/ saw it
./addmember.j            ./healthcheck.j
./app.j                  ./public/static/shelf.css
./docs/admin.md          ./src/store.j
./docs/index.md          ./src/views.j
./grimoire.toml
5 / 18

Stage one: the handbook, built by Grimoire

# syntax=docker/dockerfile:1
ARG JENNIFER_IMAGE=ghcr.io/jennifer-language/jennifer:0.26.0
ARG GRIMOIRE_IMAGE=ghcr.io/jennifer-language/grimoire:0.5.0

FROM ${GRIMOIRE_IMAGE} AS docs
COPY grimoire.toml ./
COPY docs/ docs/
RUN ["jennifer", "run", "/opt/grimoire/bin/grimoire", "build"]

Only the rendered site/ leaves this stage.

6 / 18

Stage two: the app

FROM ${JENNIFER_IMAGE}
COPY app.j addmember.j healthcheck.j /app/
COPY src/ /app/src/
COPY public/ /app/public/
COPY --from=docs --chown=root:root /work/site/ \
    /app/public/static/handbook/
WORKDIR /app
RUN ["jennifer", "lint", "app.j", "addmember.j", "healthcheck.j", \
     "src/store.j", "src/views.j"]
7 / 18

Who owns what

$ docker run --rm --entrypoint sh shelf:latest \
    -c 'id; ls -l /app; touch /app/x'
uid=10001(jennifer) gid=999(jennifer) groups=999(jennifer)
total 16
-rw-r--r-- 1 root root  919 Nov 19 17:23 addmember.j
-rw-r--r-- 1 root root 6300 Nov 19 17:23 app.j
-rw-r--r-- 1 root root  451 Nov 19 17:23 healthcheck.j
drwxr-xr-x 1 root root   12 Nov 19 17:23 public
drwxr-xr-x 1 root root   28 Nov 19 17:23 src
touch: cannot touch '/app/x': Permission denied

WORKDIR /app first would have made /app itself jennifer's.

8 / 18

Configuration: the environment

$ docker run --rm shelf:latest
shelf: set SHELF_DB_DSN, SHELF_CSRF_SECRET
$ echo $?
2
9 / 18

Secrets from files

$ docker run ... -v "$PWD/secrets:/run/secrets:ro" \
    -e SHELF_DB_DSN_FILE=/run/secrets/db_dsn \
    -e SHELF_CSRF_SECRET_FILE=/run/secrets/csrf_secret shelf:latest
app.j: runtime error at /app/app.j:30:29: fs.readString:
/run/secrets/db_dsn: open /run/secrets/db_dsn: permission denied

The files were mode 0600, owned by the host user. With 0644:

shelf: listening on [::]:8080
10 / 18

A health check without curl

try {
    def res as http.Response init http.requestWith("GET",
        "http://127.0.0.1:8080/healthz", {}, "", 2000, 4096);
    if ($res.status != 200) {
        io.printf("unhealthy: status %d\n", $res.status);
        exit 1;
    }
} catch (e) {
    io.printf("unhealthy: %s\n", $e.kind);
    exit 1;
}
11 / 18

HEALTHCHECK and what Docker makes of it

EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
    CMD ["jennifer", "run", "/app/healthcheck.j"]
CMD ["run", "app.j"]
$ docker ps --format '{{.Names}}  {{.Image}}  {{.Status}}'
shelf-app-1  shelf:latest  Up 6 seconds (healthy)
12 / 18

docker stop, measured

Programdocker stopExit code
a plain web.run0.36 s2
Shelf, catching SIGTERM0.54 s0
shelf: listening on [::]:8080
shelf: shutting down
shelf: stopped
13 / 18

compose.yaml: the database

services:
  db:
    image: mariadb:11.4
    environment:
      MARIADB_DATABASE: shelf
      MARIADB_USER: shelf
      MARIADB_PASSWORD: ${DB_PASSWORD:?set DB_PASSWORD in .env}
      MARIADB_RANDOM_ROOT_PASSWORD: "1"
    volumes: [db:/var/lib/mysql]
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 5s
14 / 18

compose.yaml: the app

  app:
    build: .
    image: shelf:latest
    depends_on:
      db: {condition: service_healthy}
    environment:
      SHELF_DB_DSN: "shelf:${DB_PASSWORD}@tcp(db:3306)/shelf"
      SHELF_CSRF_SECRET: ${CSRF_SECRET:?set CSRF_SECRET in .env}
    ports: ["127.0.0.1:8080:8080"]
    read_only: true
    cap_drop: [ALL]
    security_opt: ["no-new-privileges:true"]
15 / 18

Running and operating it

cp .env.example .env    # DB_PASSWORD, CSRF_SECRET: openssl rand -hex 32
docker compose up -d --build
docker compose logs -f app
printf '%s\n' "$PW" | docker compose exec -T app \
    jennifer run addmember.j ada
docker compose up -d --build app     # after a change: rebuild, replace
member 1: ada
16 / 18

Smaller: the distroless image

docker build --build-arg \
    JENNIFER_IMAGE=ghcr.io/jennifer-language/jennifer:0.26.0-static \
    -t shelf:static .
shelf:latest   168 MB      shelf:static   50.6 MB
$ docker run --rm --entrypoint sh shelf:static
docker: Error response from daemon: ... exec: "sh":
executable file not found in $PATH

Exec-form RUN, HEALTHCHECK and CMD only; the user is nonroot.

17 / 18

Decks, and what else to know

Based on Jennifer 0.26.0, November 2026.

18 / 18