feat(spin-node): --detach for persistent local devnets + --dockerWithSudo for genesis - #181
Merged
Merged
Conversation
Local docker mode ran each node in the foreground and tore the devnet down on exit (SIGINT/SIGTERM trap -> kill -9, plus --rm), so it never survived spin-node.sh returning. The opt-in --detach flag runs nodes with 'docker run -d --restart unless-stopped' and skips the wait/cleanup, leaving the devnet running once the script ends. The existing --stop already tears these down (docker rm -f overrides the restart policy); the detach summary now points at it for discoverability.
…needs root generate-genesis.sh called docker directly for hash-sig keygen and PK's genesis tool, so on hosts where the docker socket requires root (user not in the docker group) 'spin-node.sh --generateGenesis' failed at keygen with permission denied. Add a --dockerWithSudo flag that sudo-prefixes those docker calls (via $DOCKER_CMD), and forward it from set-up.sh when spin-node.sh receives --dockerWithSudo.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds two flags to improve running long-lived local (docker-mode) devnets: --detach to leave node containers running after spin-node.sh exits, and --dockerWithSudo to allow genesis generation on hosts where Docker requires root access.
Changes:
- Add
--detachsupport to run local docker nodes viadocker run -d --restart unless-stoppedand skip the trap/wait cleanup path. - Add
--dockerWithSudosupport for genesis generation by routing Docker invocations throughsudo docker. - Forward
--dockerWithSudofromset-up.shintogenerate-genesis.sh, and surfacedetachNodesin env parsing/debug output.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spin-node.sh | Adds detached docker-run mode and alters end-of-script behavior to skip trap/wait/cleanup when detached. |
| set-up.sh | Forwards --dockerWithSudo to the genesis generator. |
| parse-env.sh | Parses --detach and prints detachNodes in the env summary output. |
| generate-genesis.sh | Implements --dockerWithSudo via a DOCKER_CMD wrapper for docker pull/run operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…s sudo-aware Address PR review: - Fail fast if --detach is used with a binary node. --detach relies on docker's --restart unless-stopped to outlive the script; a binary has no supervisor, so it would run in the foreground (or die on exit). Guard it right after the client cmd is sourced (earliest point node_setup is known). - Make the detached-mode hints honor --dockerWithSudo: prefix docker logs/rm with sudo and forward --dockerWithSudo to the suggested --stop command, so copy-pasted hints work on hosts where the docker socket needs root.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two quality-of-life additions for running local (docker-mode) devnets, aimed at long-lived devnets on remote hosts:
--detach(spin-node.sh,parse-env.sh): start a local devnet that keeps running after the script exits.--dockerWithSudo(generate-genesis.sh,set-up.sh): let genesis generation work on hosts where the docker socket needs root.--detachBy default the local docker path runs each node as
docker run --rm ... &and installs atrap cleanupthatkill -9s the containers when the script exits. That's correct for the interactive / timeout-wrapper workflow, but means you can't leave a devnet running on a server.With
--detach:--detachdocker run --rm(foreground&)docker run -d --restart unless-stoppedtrap cleanupkills nodeswaiton pidsForeground behavior is unchanged when the flag is absent (Chesterton's fence: the trap/
wait/--rmpath is preserved for the timeout wrapper and interactive use).Stopping a detached devnet uses the existing
--stoppath:--dockerWithSudoOn hosts where the invoking user is not in the
dockergroup,generate-genesis.sh's docker calls (hash-sig-clikeygen andeth-beacon-genesis) fail.--dockerWithSudoroutes those twodockerinvocations throughsudo docker.set-up.shforwards the flag through when it drives the generator.Both docker runs keep
--user "$UID:$GID"so files written by a sudo'd container are still owned by the invoking user, not root.Testing
--detach(foreground path unchanged; detached path leaves containers up and--stoptears them down).--dockerWithSudogenesis generation on a host where docker requires root.