Repository navigation
Ship staging from the on-prem runner over its private address - #84
Merged
Merged
Conversation
Staging was the only reason any host in this VPC needed SSH open to the public internet: its deploy ran on GitHub-hosted runners, which can reach it no other way, so the shared security group carries 22/tcp from 0.0.0.0/0 and ::/0. Restricting that to GitHub's ranges is not viable — Actions runners egress from Azure prefixes numbering in the thousands and rotating, well past the per-group rule limit. Reaching the host over the VPN instead removes the requirement rather than trying to narrow it. That needs the deploy split in two. Building still wants Docker and a few minutes of Rust compile, which does not belong on an on-prem runner; shipping needs only ssh and tar. So the mechanics move into a reusable workflow with a `build` job on hosted infrastructure and a `ship` job wherever the target is reachable, and only the finished binary crosses into the private network. The ship runner's own architecture is irrelevant — it never executes the binary. Make the build target-architecture aware while here. build.sh hardcoded linux/arm64 and deploy.sh always fetched an arm64 Caddy, so pointing either at an x86_64 host produced a unit that installed cleanly and then crash-looped on "Exec format error" — a failure that reads like an app bug rather than a build-target mistake. build.sh now honours $ARCH, deploy.sh derives Caddy's architecture from the host's uname, and it compares the binary's ELF e_machine against the host before shipping anything, so a mismatch aborts with the exact rebuild command instead of taking the service down. After each deploy the ship job reads GET /version on the host and asserts the reported commit matches what was built, so a restart that silently kept the old binary fails the run instead of passing quietly. It reads over SSH from the host so this works even when the domain does not resolve from the runner. DEPLOY_HOST must change to the host's private address before this lands, or the ship job will try to reach the old public address from inside the VPN. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh
There was a problem hiding this comment.
Pull request overview
This PR refactors the native (Docker-free) staging deploy so the build happens on a GitHub-hosted runner while the “ship” step runs on a self-hosted on-prem runner that can reach the staging host over its private/VPN address, eliminating the need for public inbound SSH. It also hardens deploy correctness by adding architecture targeting/verification and post-deploy version verification.
Changes:
- Introduces a reusable
deploy-native.ymlworkflow split intobuild(hosted) andship(reachability-constrained) jobs, and updatesdeploy.ymlto call it for staging. - Adds
ARCHsupport todeploy/native/build.sh, updatesdeploy/native/deploy.shto download the correct Caddy arch and to validate the shipped binary’s arch vs the host. - Expands native deploy documentation, including dual-stack reachability caveats and the build/ship model.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
deploy/native/README.md |
Updates deploy docs to reflect build/ship split, arch support, and dual-stack reachability guidance. |
deploy/native/deploy.sh |
Adds ELF/arch checks before shipping and downloads the correct Caddy binary for the host arch. |
deploy/native/build.sh |
Adds ARCH selection/normalization and threads it through the container build platform. |
.github/workflows/deploy.yml |
Switches staging deploy to call the reusable workflow and ships from the on-prem runner. |
.github/workflows/deploy-native.yml |
New reusable workflow implementing the two-job build/ship deploy with post-deploy /version verification. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Match all four ELF magic bytes in deploy.sh rather than the three that follow the leading 0x7F. The old check skipped byte 0, so a payload whose 2nd-4th bytes spelled "ELF" passed it; verified end-to-end against a stubbed ssh that such a file is now rejected before anything ships, while a real binary still passes and a genuine arch mismatch still aborts with the rebuild hint. Two comments in deploy-native.yml overclaimed. The header said the build job runs on a GitHub-hosted arm64 runner when it runs on whatever inputs.build_runs_on names, which normally tracks inputs.arch. The supply-chain note said third-party actions are pinned to a commit SHA while setup-node, upload-artifact and download-artifact all float on a major tag; the comment now describes what is actually pinned rather than the intent. Pinning the remaining three needs SHAs not recorded anywhere in this repository, so that stays a follow-up. Also add the missing "that" in the per-arch assembly paragraph. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh
Both workflow headers pointed at deploy-release.yml, which this branch does not add — it arrives with the production release-tag workflow. Standing alone the references dangle, and this branch is meant to merge first and prove the on-prem ship path on staging before production follows, so the window where they point at nothing is not necessarily short. Describe what is actually here instead: deploy.yml is the one caller, and the mechanics are parameterised by environment, runner and architecture so a second caller can drive production without duplicating them. The comments name deploy-release.yml again in the branch that adds it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01R8ZshwKmjD5fZ4Hs9dS6zh
This was referenced Jul 27, 2026
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.
Replaces #83, which GitHub auto-closed as merged when a force-push made its head an ancestor of its then-base. Nothing reached
main; this is the same change, now based directly onmainand self-contained.Summary
Staging is the only reason any host in this VPC needs SSH open to the public internet. Its deploy runs on GitHub-hosted runners, which can reach it no other way, so at the time the shared security group carried
22/tcpfrom0.0.0.0/0and::/0. Restricting that to GitHub's ranges isn't viable — Actions runners egress from Azure prefixes numbering in the thousands and rotating, well past the per-group rule limit. Reaching the host over the VPN instead removes the requirement rather than trying to narrow it.That needs the deploy split in two. Building still wants Docker and a few minutes of Rust compile, which doesn't belong on an on-prem runner; shipping needs only
sshandtar. So the mechanics move into a reusable workflow with abuildjob on hosted infrastructure and ashipjob wherever the target is reachable, and only the finished binary crosses into the private network. The ship runner's own architecture is irrelevant — it never executes the binary.Two latent problems surfaced while wiring this up and are fixed here:
build.shhardcodedlinux/arm64anddeploy.shalways fetched an arm64 Caddy. Pointing either at an x86_64 host produced a unit that installed cleanly and then crash-looped onExec format error— a failure that reads like an app bug rather than a build-target mistake.systemctl restartthat silently kept the old one would have passed as a green deploy.Related issues
None.
Changes
deploy-native.yml, a reusable workflow holding the deploy mechanics, split intobuild(hosted, needs Docker) andship(reachability-constrained, needs only ssh + tar).deploy.ymlcalls it, runs in astagingenvironment, and ships from the on-prem runner.build.shan$ARCHknob (arm64/amd64, accepting theuname -mspellings too) and thread it through the build container.deploy.shderive Caddy's download architecture from the host'suname -m, and compare the binary's ELFe_machineagainst the host before shipping anything — a mismatch aborts with the exact rebuild command instead of taking the service down.github.sha, which points at the default branch on aworkflow_dispatchrun and would have mislabelled the binary.GET /versionreports the just-built commit after each deploy, read over SSH from the host so it works when the domain isn't resolvable from the runner.Testing
build.shanddeploy.shpassbash -n.deploy.shend-to-end against a stubbedssh, and confirmed the rendered remote script parses as bash and substitutesPUBLIC_URL, the Caddy domain, and the dashboard's allowlist correctly.$(uname -m)in the Caddy block survives heredoc escaping and evaluates on the host rather than locally.e_machineprobe verified against a real x86-64 binary and synthesized aarch64, LoongArch and big-endian headers.src/main.rsthat/versionreports the field ascommit.ARCH=amd64container build — no Docker daemon in the authoring sandbox. Thearm64path is unchanged from what has been deploying green.cargo build/cargo test/clippy— no Rust source changed.Checklist
Required before merge
Update the
DEPLOY_HOSTrepository secret to staging's private address. The ship job runs inside the VPN, so the current public value is unreachable from there and the first run after merge fails at the SSH step.(Retrospect: this was the right instruction and it did not stick.
DEPLOY_HOSTwas later set to staging's public FQDN, so staging's deploys travelled over the internet rather than the VPN for some time — undetected until the public interface stopped permitting22. The requirement is now stated on the secret's own description indeploy-native.yml, per #102.)Once a deploy goes green from on-prem,Superseded — the22/tcpcan be revoked from0.0.0.0/0and::/0onimcp2-weband replaced with an SSH group scoped to the runner's range.::/0half was removed, and revoking the0.0.0.0/0half broke the deploy, because the runners present no stable range to scope a group to. What actually closed the internet path was separating the public-facing and deploy network interfaces onto different security groups. See #91.Generated by Claude Code