Skip to main content

Raku on Miren

Raku isn't auto-detected, so you deploy it with a Dockerfile.miren. This guide uses Cro, the standard Raku framework for building HTTP services.

Let your agent do this

Ask your AI coding agent to "set up this Raku app on Miren" after installing the Miren agent skills. It adds the Dockerfile.miren, binds the server to 0.0.0.0:$PORT, and deploys — using this page as its reference.

Does this source build need a Dockerfile?

Yes. Miren doesn't auto-detect Raku, so add a Dockerfile.miren to your project root. Miren builds from it instead of guessing the stack — see Using Dockerfile.miren.

Want native support?

Miren auto-detects and builds common stacks (Python, Node, Bun, Go, Ruby, Rust) without a Dockerfile. This language isn't one of them yet — if you'd like first-class support, request it.

Bind to the injected port

Miren injects PORT and routes traffic to it, so read PORT and bind 0.0.0.0. The final sleep; keeps the process alive after the server starts in the background:

use Cro::HTTP::Server;
use Cro::HTTP::Router;

my $application = route {
get -> {
content 'text/plain', "Hello from Raku on Miren!\n";
}
}

my $port = %*ENV<PORT> // 8080;
my Cro::Service $service = Cro::HTTP::Server.new(
:host('0.0.0.0'), :port(+$port), :$application,
);
$service.start;
say "listening on 0.0.0.0:$port";
sleep;

The Dockerfile

Create Dockerfile.miren in your project root. The rakudo-star image bundles Rakudo and the zef package manager; Cro's TLS support links against OpenSSL, so install libssl-dev before zef install:

FROM rakudo-star:latest
RUN apt-get update -y && apt-get install -y libssl-dev && rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN zef install --/test Cro::HTTP
COPY . /app
EXPOSE 8080
CMD ["raku", "/app/app.raku"]
Cro needs the OpenSSL headers

Without libssl-dev, installing Cro::HTTP fails while compiling Cro::TLS with Cannot locate native library 'libssl.so'. The dev package provides the libssl.so symlink Cro's native bindings look for.

.dockerignore

.git

Deploy

The Dockerfile's CMD starts the app. Miren uses it as the web service's startup default, so you don't need a Procfile or service command.

Create .miren/app.toml naming your app and deploy from your project root:

name = "raku-bench"
miren deploy

Environment variables

Set variables with miren env set-e for plain values, -s for secrets (masked in output and logs). Read them with %*ENV<KEY>:

miren env set -e LOG_LEVEL=info
miren env set -s DATABASE_URL

See App Configuration — Environment Variables.

Agent quick reference

  • Detection: none — requires Dockerfile.miren
  • Base image: rakudo-star:latest (Rakudo + zef); zef install --/test Cro::HTTP
  • OpenSSL: install libssl-dev before zef install or Cro::TLS fails to build
  • Startup: inherited from the Dockerfile CMD; no Procfile or service command needed
  • Keep-alive: end with sleep; so the process stays up after $service.start
  • Port: %*ENV<PORT>; Cro::HTTP::Server.new(:host('0.0.0.0'), :port(...))
  • Env vars: miren env set -e/-s; read with %*ENV<KEY>

Next steps