These libraries are experimental. APIs may change without notice. Generated from source on 3/14/2026.
Docker
@korulang/docker - Docker DSL for Koru
@koru/docker
@korulang/docker - Docker DSL for Koru
Declarative image definitions and typed container lifecycle.
Phantom obligations ensure containers are properly stopped.
DECLARATIVE IMAGES:
~koru.docker:image(tag: "myapp:latest") {
FROM alpine:3.18
COPY zig-out/bin/main /usr/local/bin/myapp
CMD ["myapp"]
}
CONDITIONAL IMAGES (build flags):
~[build("prod")]koru.docker:image(tag: "myapp:latest") {
FROM alpine:3.18
COPY zig-out/bin/main /usr/local/bin/myapp
CMD ["myapp"]
}
~[build("dev")]koru.docker:image(tag: "myapp:latest") {
FROM alpine:3.18
RUN apk add --no-cache gdb strace
COPY zig-out/bin/main /usr/local/bin/myapp
CMD ["myapp", "--debug"]
}
Then run: koruc main.kz --build=prod docker build
This generates Dockerfiles and builds all declared images matching the flag.
~[comptime|command]pub event docker {
program: *const Program,
allocator: __koru_std.mem.Allocator,
argv: []const []const u8,
}// ============================================================================
// Declarative Image Definition (compile-time)
// ============================================================================
//
// Declare a Docker image - collected at compile time, generates Dockerfile
// Usage:
// ~koru.docker:image(tag: "myapp:latest") {
// FROM node:18-alpine
// WORKDIR /app
// COPY . .
// CMD ["node", "index.js"]
// }
~[comptime|norun]pub event image {
tag: []const u8, source: Source
}// ============================================================================
// Build Operations
// ============================================================================
~pub event build {
tag: []const u8, context: []const u8
}
| built { image: Image }
| failed { code: i32, msg: []const u8 }// ============================================================================
// Container Lifecycle (with phantom obligations)
// ============================================================================
//
// Run a container - creates [running!] obligation that must be discharged
~pub event run {
image: []const u8, name: ?[]const u8
}
| started { container: Container[running!] }
| failed { code: i32, msg: []const u8 }// Stop a container - discharges [running!] obligation
~pub event stop {
container: Container[!running]
}
| stopped {}
| failed { code: i32, msg: []const u8 }// Kill a container (forceful) - also discharges [running!] obligation
~pub event kill {
container: Container[!running]
}
| killed {}
| failed { code: i32, msg: []const u8 }// ============================================================================
// Registry Operations
// ============================================================================
~pub event push {
image: []const u8
}
| pushed {}
| failed { code: i32, msg: []const u8 }~pub event pull {
image: []const u8
}
| pulled {}
| failed { code: i32, msg: []const u8 }