Skip to content

Commit cb0f73e

Browse files
committed
feat: add pyhl container image for device plugin deployments
Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent 71c543b commit cb0f73e

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

host/pyhl-entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ ! -d "$PYHL_HOME/snapshot" ]; then
5+
staging=$(mktemp -d)
6+
mkdir -p "$staging/.unikraft/build"
7+
ln -s "$PYHL_HOME/kernel" "$staging/.unikraft/build/driver_hyperlight-x86_64"
8+
ln -s "$PYHL_HOME/initrd.cpio" "$staging/driver-initrd.cpio"
9+
pyhl setup --dest "$PYHL_HOME" --from "$staging" --net --force
10+
rm -rf "$staging"
11+
fi
12+
13+
exec pyhl run --dest "$PYHL_HOME" --net "$@"

host/pyhl.Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# pyhl container image — runs Python scripts in Hyperlight micro-VMs.
2+
#
3+
# Bundles the pyhl CLI, the python-agent-driver kernel, and its initrd
4+
# into a single runnable container. Designed for the
5+
# hyperlight-on-kubernetes device plugin: the pod gets /dev/kvm via
6+
# `hyperlight.dev/hypervisor: "1"` and pyhl handles the rest.
7+
#
8+
# Build (from repo root):
9+
# docker build -f host/pyhl.Dockerfile -t pyhl .
10+
#
11+
# Run:
12+
# docker run --rm --device /dev/kvm pyhl /path/to/script.py
13+
# echo 'print("hi")' | docker run --rm -i --device /dev/kvm pyhl -
14+
15+
FROM rust:1.87-bookworm AS builder
16+
COPY host/ /src/host/
17+
WORKDIR /src/host
18+
RUN cargo build --release --bin pyhl
19+
20+
FROM ghcr.io/hyperlight-dev/hyperlight-unikraft/python-agent-driver-kernel:latest AS kernel
21+
FROM ghcr.io/hyperlight-dev/hyperlight-unikraft/python-agent-driver-initrd:latest AS initrd
22+
23+
FROM debian:bookworm-slim
24+
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \
25+
&& rm -rf /var/lib/apt/lists/*
26+
COPY --from=builder /src/host/target/release/pyhl /usr/local/bin/
27+
COPY --from=kernel /kernel /opt/pyhl/kernel
28+
COPY --from=initrd /initrd.cpio /opt/pyhl/initrd.cpio
29+
COPY host/pyhl-entrypoint.sh /entrypoint.sh
30+
RUN chmod +x /entrypoint.sh && chown -R 65534:65534 /opt/pyhl
31+
ENV PYHL_HOME=/opt/pyhl
32+
USER 65534
33+
ENTRYPOINT ["/entrypoint.sh"]

0 commit comments

Comments
 (0)