HUB
Sign inSign up

paularlott/frankenscriptling

By paularlott

•Updated 4 days ago

Docker images bundling FrankenPHP with the Scriptling scripting language, exposed as a PHP class

Image
Machine learning & AI
Developer tools
0

10K+

paularlott/frankenscriptling repository overview

⁠FrankenScriptling

FrankenScriptling combines FrankenPHP⁠ (a modern PHP application server built on top of Caddy) with the Scriptling⁠ scripting language, exposing a full Scriptling VM as a native PHP class.

Each new Scriptling() instance creates an isolated VM with Python-like syntax, support for libraries (JSON, regex, math, YAML, TOML, AI/LLM, and more), variable sharing between PHP and Scriptling, and output/error capture — all running in-process via a FrankenPHP extension with zero HTTP overhead.

See the GitHub repo⁠ for full documentation.

⁠Quick start

docker pull paularlott/frankenscriptling:php8.5

Create public/index.php:

<?php
$vm = new Scriptling();

echo $vm->eval('1 + 1');   // 2

Serve it (the default Caddyfile serves /app/public on port 80):

docker run --rm -p 8080:80 -v "$PWD/public:/app/public" paularlott/frankenscriptling:php8.5

Open http://localhost:8080⁠ and you'll see 2.

Or run it from the command line without a web server:

docker run --rm paularlott/frankenscriptling:php8.5 \
  frankenphp php-cli -r 'echo (new Scriptling())->eval("1 + 1"), PHP_EOL;'

⁠A little more

<?php
$vm = new Scriptling();
$vm->setVar('name', 'world');

$result = $vm->eval('
import json
greeting = "Hello, " + name
json.dumps({"greeting": greeting, "sum": sum([1, 2, 3])})
');

echo $result;   // {"greeting": "Hello, world", "sum": 6}

if ($vm->hasError()) {
    echo $vm->getLastError();
}

⁠The image

A drop-in replacement for the official FrankenPHP image, at less than half the size (about 470MB against 1GB):

  • Same PHP, environment and layout. It's the official FrankenPHP PHP build (/usr/local, with the PHP source in /usr/src) on a bare debian:trixie-slim. The environment (PHP_INI_DIR, PHPIZE_DEPS, …), entrypoint, /app, ports and health check all match.
  • Same build as the official binary. It has the same build tags and compiler flags, and reports itself the same way: frankenphp version and the Server: FrankenPHP Caddy header. It includes the Mercure hub, Vulcain and Brotli, plus Cloudflare DNS and transform-encoder.
  • Survives config reloads. Stock FrankenPHP drops Go extensions such as Scriptling when its config is reloaded through the admin API /load or --watch (php/frankenphp#2572⁠). This build is patched so the Scriptling class stays available.
  • Rootless-ready. frankenphp already has cap_net_bind_service, and /config and /data belong to www-data, so USER www-data is all it takes to run without root.

⁠Adding PHP extensions

There's no compiler in the image. install-php-extensions and docker-php-ext-configure / -install / -enable install the toolchain when they need it and remove it afterwards, keeping only the libraries the new extensions link against. The official Alpine images do the same. A toolchain you install yourself is left alone.

FROM paularlott/frankenscriptling:php8.5

# Core and PECL extensions alike
RUN install-php-extensions pdo_mysql gd intl zip redis xdebug

# Or the official PHP image way, for core extensions
RUN apt-get update && apt-get install -y libfreetype-dev libjpeg62-turbo-dev libpng-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

Keep docker-php-ext-configure and docker-php-ext-install in the same RUN. A bare pecl install or phpize fails with Cannot find autoconf; use install-php-extensions, or install $PHPIZE_DEPS yourself in the same RUN and remove it afterwards.

⁠Security

Scriptling libraries that can touch the filesystem or network (os, pathlib, requests, subprocess, …) are disabled by default. An operator enables them through environment variables or a policy file (SCRIPTLING_POLICY_FILE), with allowed paths and a network policy (HTTPS only, no private or internal addresses, host allow/deny lists). PHP code can never loosen the policy. Per-VM memory limits are also available. See docs/security-policy.md⁠.

⁠Adding Caddy modules

Builder images follow FrankenPHP's pattern. build-frankenscriptling uses the same modules, build tags and compiler flags as the published binary, and adds yours:

FROM paularlott/frankenscriptling:0.33.0-builder-php8.5 AS builder
RUN build-frankenscriptling --with github.com/acme/[email protected]

FROM paularlott/frankenscriptling:0.33.0-php8.5
COPY --from=builder /usr/local/bin/frankenphp /usr/local/bin/frankenphp
RUN setcap cap_net_bind_service=+ep /usr/local/bin/frankenphp

Pair a builder with the runtime tag of the same release so PHP matches.

⁠Tags

TagMoves?Meaning
0.33.0-php8.5.12noRelease 0.33.0 on exactly PHP 8.5.12
0.33.0-php8.5noThe same build, named by PHP line
php8.5, php8.4yesNewest release for that PHP line
latestyesNewest release on the newest PHP line
0.33.0-builder-php8.5.12, 0.33.0-builder-php8.5, builder-php8.5, builderas aboveMatching builder images

Pin a full version tag in production. Images are multi-arch (linux/amd64, linux/arm64).

Tag summary

Content type

Image

Digest

sha256:221e205d9…

Size

118.5 MB

Last updated

4 days ago

docker pull paularlott/frankenscriptling