Skip to content

feat: per-task setup hook so stock AL2023 works (#47) - #48

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/47-per-task-setup-hook
Jun 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/47-per-task-setup-hook

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Closes #47. (Good news in the report: #45 is validated end-to-end in the demo.) After moving the Kraken2 DB onto an EBS volume, the only remaining reason to maintain a custom AMI was Docker/pigz on the task instances — this removes it.

The gap

nf-spawn runs the task's container with docker run on the instance, and demo processes call pigz/ethtool/aws on the host — but there was no hook to install anything, so every task instance had to be a custom AMI with Docker + tools pre-baked. Stock AL2023 has the AWS CLI but no Docker, so it couldn't be used.

Fix — a per-task setup step, injected into the staging script before the task

All three composable layers from the issue:

  1. Auto-ensure Docker — when a process has a container directive (nf-spawn always runs it via docker run), install + start Docker if it isn't present. Idempotent: command -v docker guards the install, so a pre-baked AMI pays nothing. Opt out with ext.ensureDocker = false. This is the part that makes stock AL2023 "just work" for the common containerized case, zero config.
  2. ext.packages = ['pigz', 'ethtool'] → dnf install -y of host tools. Accepts a list or a space/comma string.
  3. ext.setup = '<shell>' → arbitrary bootstrap, run last.

buildSetupScript(ext, container) composes them; buildStagingScript runs the result before the work-dir sync and the task. Empty when there's nothing to do.

Combined with ext.volumes (0.3.0), the full stock AMI + DB-on-EBS + tools-at-launch setup is now reachable — no custom AMI.

Caveat (documented)

Per-task installs add boot latency + a repo failure mode. The README notes that a small pre-baked tools AMI is the lower-latency option for wide fan-out — but now it's a choice, not a requirement.

Tests

48 total, 0 failures. Added: auto-ensure Docker only when a container is set; idempotent guard present; ext.ensureDocker=false opt-out; ext.packages dnf line; ext.setup ordering (after docker); parsePackages (list / space / comma / empty); and end-to-end that setup runs before the sync and the task. README ext table + stock-AMI note updated. Built/tested on JDK 17.

nf-spawn ran the task container with `docker run` on the instance but provided
no way to install Docker/tools first, so every task instance had to be a custom
AMI with Docker (+ pigz etc.) pre-baked — even after ext.volumes (#45) moved
the reference DB out of the AMI. This adds a per-task bootstrap, injected into
the staging script before the task:

- Auto-ensure Docker when a `container` directive is set — install + start it if
  absent (idempotent; stock AL2023 has the AWS CLI but no Docker). Opt out with
  `ext.ensureDocker = false` for a pre-baked tools AMI.
- `ext.packages = ['pigz', ...]` → dnf install of host tools (list or
  space/comma string).
- `ext.setup = '<shell>'` → arbitrary bootstrap, run last.

buildSetupScript composes the three (parsePackages normalizes the list);
buildStagingScript runs the setup before the work-dir sync and the task.

With ext.volumes, the full stock-AMI + DB-on-EBS + tools-at-launch setup is now
reachable — no custom AMI required.
@scttfrdmn
scttfrdmn merged commit 85dd8c0 into main Jun 14, 2026
1 check passed
@scttfrdmn
scttfrdmn deleted the feat/47-per-task-setup-hook branch June 14, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No per-task setup/bootstrap hook → tasks require Docker/tools pre-baked in a custom AMI (can't use stock AL2023)

1 participant