Repository navigation
Description
The gap
nf-spawn's task staging runs the task's container with docker run … directly on the instance (SpawnTaskHandler.buildStagingScript / buildRunLine), and the demo's processes also call aws s3, pigz, ethtool on the host. But nf-spawn provides no way to run a setup/bootstrap step before the task — buildLaunchCommand forwards only instanceType / region / ttl / spot / ami / volumeSize / volumes, and the staging script assumes Docker (and everything else) is already present.
Consequence: every task instance must be a custom AMI with Docker + tools pre-baked. You cannot point nf-spawn at stock AL2023, because stock AL2023 has the AWS CLI but no Docker and no pigz, and there's no hook to install them at launch.
Why this matters
It partly defeats the decoupling that ext.volumes (#45) just enabled. We moved the Kraken2 DB out of the AMI onto an EBS volume specifically so we could stop maintaining a custom AMI — but we're still forced to bake one just for Docker/pigz. So the AMI maintenance burden (per-arch bakes, version drift, rebakes) doesn't actually go away. The ideal end-state — stock AL2023 + DBs on EBS volumes + tools installed at launch — isn't reachable today.
spawn already has the primitive
spawn launch exposes --command ("Command to run on all instances, executed after spored setup"), plus --user-data and --plugin. So the underlying capability is there — nf-spawn just doesn't forward it.
Proposal
Give nf-spawn a per-process setup hook, e.g.:
process {
withName: '.*' {
ext.setup = 'dnf install -y docker pigz && systemctl start docker'
// or a higher-level: ext.ensureDocker = true
}
}mapped to spawn launch --command <setup> (run before the task's docker run). Options, roughly increasing in convenience:
ext.setup/ext.command— forward an arbitrary per-task bootstrap tospawn launch --command. Minimal, general.ext.packages = ['docker','pigz']— nf-spawn emits thednf install+systemctl start docker. Friendlier for the common case.- Auto-ensure Docker — since nf-spawn always needs Docker to run a
containertask, it could detect "container directive present" and ensure Docker is installed/started in the staging script itself (idempotent: skip if already present). This makes stock AMIs "just work" for the overwhelmingly common containerized-task case with zero config.
(3) is the one that most directly unlocks stock AL2023; (1)/(2) cover the host-side extras like pigz. They compose.
Caveat to weigh
Installing packages per task adds boot latency and a network/repo failure mode to every task. A pre-baked tools AMI avoids that. So the ideal is probably: support the hook (so stock-AMI works out of the box), but document that a small tools AMI is the low-latency option for wide fan-out. Right now there's no choice — it's custom-AMI-or-nothing.
Context
Found finishing the aws-microbiome-demo Graviton migration. After moving the Kraken2 DB to an EBS volume (#45, validated end-to-end), the only remaining reason we maintain a custom AMI is Docker/pigz on the task instances — exactly what this hook would remove. nf-spawn 0.3.0, spawn 0.49.0, AL2023 arm64. Happy to test against the demo.
Activity
feat: per-task setup hook so stock AL2023 works (#47) (#48)
scttfrdmn commentedon Jun 14, 2026
Shipped in nf-spawn v0.4.0 (#48). All three layers, composable:
containerdirective — nf-spawn installs + starts Docker on the instance if it's not already there (idempotentcommand -v dockerguard, so a pre-baked AMI pays nothing). Opt out withext.ensureDocker = false.ext.packages = ['pigz', 'ethtool']→dnf installof host tools (list or space/comma string).ext.setup = '<shell>'→ arbitrary bootstrap, run last.These run in the staging script before the work-dir sync and the task. With
ext.volumes(0.3.0), the end-state you wanted — stock AL2023 + DB on EBS + tools at launch — is now reachable with no custom AMI:process { withName: 'KRAKEN2_KRAKEN2' { ext.instanceType = 'r7g.2xlarge' ext.volumes = [[ snapshot: 'snap-0abc', mount: '/opt/databases/kraken2', readOnly: true ]] ext.packages = ['pigz'] // Docker is auto-ensured; add host extras here // ext.ami omitted → stock AL2023 } }Per your caveat: this adds per-task install latency + a repo failure mode, so for wide fan-out a small pre-baked tools AMI is still the lower-latency option — but now that's a choice, not a requirement. README documents the tradeoff.
Bump
TARGET_NF_SPAWN_VERSIONto0.4.0to try it. Since #45 already validated end-to-end, this should let you drop the custom AMI entirely on the demo — keen to hear if stock AL2023 runs clean. (Note: first containerized task on a fresh stock instance pays the one-timednf install docker; that's expected.)