Repository navigation
Add secure GHCR-to-VPS deployment with health checks and rollback - #222
Merged
Merged
Conversation
SlimShadyIAm
force-pushed
the
codex/secure-vps-deployment
branch
from
October 24, 2026 21:34
4534692 to
b630943
Compare
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.
Adds a deployment path for the bot that builds images in GitHub Actions and deploys an immutable GHCR digest over a restricted SSH connection. PRs build and check the image; main publishes releases. VPS deployment remains disabled until the repository variable VPS_DEPLOY_ENABLED=true and the production environment secrets are configured.
The deploy account has no Docker membership or general-purpose sudo access. Its authorized key is restricted to a root-owned forced command, which validates a digest from this repository's fixed GHCR image and uses a root-owned Compose configuration. The server pulls before replacing the bot, serializes deployments with flock, waits for a Discord readiness heartbeat after startup cache loading, and restores the last successful image if the candidate fails readiness. First-deployment failure stops the candidate and requires the documented legacy-service restart. Successful image references are retained for manual rollback.
The runtime uses Python 3.12, a non-root user, a read-only filesystem, dropped capabilities, no-new-privileges, bounded logs, and a writable tmpfs. Secrets/configuration are excluded from images and supplied on the VPS. The legacy local Compose service now loads .env and mounts config.json at runtime to accommodate those exclusions. Host networking is retained for existing localhost MongoDB setups.
See deploy/README.md for VPS installation, the forced SSH key, sudoers rule, verified host keys, optional read-only GHCR authentication, GitHub production environment settings, first-deployment migration, and rollback/operational limitations. Deployment requires manual VPS preparation; this PR does not contact or change the VPS.
Validation:
Live GHCR publication and SSH deployment require the production credentials and have not been exercised.