gabriel / musehub public
10-11-automated-deployment.md markdown
90 lines 6.8 KB
Raw
sha256:bba4b69de173366aeb7d490d687ccffb6db9726374033addece89cf2b87642d8 docs: add production launch discovery report and infra laun… Sonnet 5 8 days ago

Sections 10 & 11 — Automated Staging and Production Deployment

Companion to musehub-production-readiness-checklist.md. Covered together: both sections assume automated deploy pipelines that don't exist yet. Today's reality (Section 0): a human runs bash deploy/push.sh staging|prod from a laptop, using the shared musehub-infra credential. There is no trigger-on-push, no approval gate, no automatic rollback — everything is manual and synchronous.

What already exists and is worth keeping

deploy/push.shdeploy/deploy.sh already implements several things both sections ask for, just manually-triggered rather than automated:

  • [x] Deploy the immutable application artifact — ECR image, tagged, pulled by digest on the instance
  • [x] Run database migrations — automatic, before slot swap (Section 8)
  • [x] Run health checks — /healthz gates the blue/green flip
  • [x] Blue/green deployment — the actual deploy strategy in use (satisfies "deploy using rolling/blue-green/canary" from Section 11)
  • [x] A documented manual deployment path (Section 11's explicit ask for an emergency path) — this is the current path, so it trivially exists; worth keeping even after automation exists
  • [x] A documented rollback command — IMAGE_TAG=<previous-tag> bash deploy/push.sh <env>, per docs/infrastructure.md
  • [ ] Rollback has not been tested in this pass (checklist explicitly requires testing it, not just having the command)

What's missing — and why it's bigger than "add a pipeline"

Per Section 9's finding, MuseHub doesn't yet have the platform primitives (branch protection, required checks, merge gating) that a "deploy on merge to dev" trigger would normally hook into. That means Sections 10–11 have two layers of work, not one:

  1. Trigger mechanism — something needs to fire on push/merge. Options: a MuseHub webhook (muse hub webhook create) calling out to a deploy runner, or the musehub-runner container (once its job-execution client is actually built per Section 9) running the deploy as a job type. Either is real, currently-nonexistent work.
  2. Everything downstream of the trigger — OIDC-style AWS auth (no more shared laptop credential), staging/production role separation, approval gating for production, notifications, concurrent-deploy locking, structured deploy records (artifact digest/migration version/ deployer/timestamp).

Section 10 — Automated Staging Deployment — item-by-item

  • [ ] Create a MuseHub-native "staging environment" concept (GitHub environment equivalent) — doesn't exist
  • [ ] Deploy automatically after merges to dev/main — not started; no trigger mechanism exists
  • [ ] Authenticate to AWS through short-lived credentials (OIDC-equivalent) — not started; still the shared musehub-infra key
  • [ ] No long-lived AWS keys in CI config — currently moot, no CI config exists; becomes relevant once a trigger mechanism does
  • [ ] Restrict the staging role to staging-only resources — not started (Section 3 dependency)
  • [ ] Infra planning/apply as a pipeline step — N/A, no IaC yet (Section 4)
  • [x] Deploy the immutable artifact — already true, manually
  • [x] Run migrations — already true, automatic within the deploy
  • [ ] Run smoke tests — not automated; no smoke-test suite identified in this pass (worth checking deploy/smoke_muse.sh's actual coverage separately)
  • [x] Run health checks — already true
  • [ ] Publish deployment URL + commit SHA — not automated; would need to reference MuseHub commit IDs, not git SHAs
  • [ ] Notify both maintainers of success/failure — not automated
  • [ ] Preserve deployment logs — not done; deploy output currently only lives in the triggering laptop's terminal
  • [ ] Automatic rollback on health-check failure — not automated, but deploy.sh's health-gated blue/green already prevents a bad slot from going live in the first place (the new slot must pass /healthz before nginx flips to it) — so the failure mode is "deploy doesn't complete" rather than "bad deploy goes live and needs rollback." Worth confirming this distinction is enough, or whether explicit rollback automation is still wanted.
  • [ ] Database rollback kept separate/explicit — not formalized
  • [ ] Prevent concurrent staging deploys from colliding — not enforced; two people running push.sh staging simultaneously today would race
  • [ ] Deployment status visible in MuseHub — not built
  • [ ] Record artifact digest/migration version/deployer/timestamp — not recorded anywhere structured

Section 11 — Automated Production Deployment — item-by-item

Everything in Section 10 applies again for production, plus:

  • [ ] Distinct production AWS role — not started (Section 3)
  • [ ] Explicit release trigger (version tag / MuseHub release / manual promotion) — MuseHub already has a release feature (muse release add/muse hub release create) that could serve this purpose; not currently wired to deploy at all
  • [ ] Promote the exact staging-tested artifact rather than rebuilding — not done by default; possible via IMAGE_TAG (Section 9), not the default flow
  • [ ] Require successful staging deployment/tests first — not enforced
  • [ ] Require production approval, prevent self-approval, allow both Gabriel and Aaron to approve — not built; also blocked on Section 1/3 (Aaron has no independent deploy identity yet)
  • [ ] Display full deployment plan before approval — not built
  • [ ] Back up stateful systems before risky changes — currently impossible to do meaningfully, no backups exist (Section 8)
  • [x] Run migrations as a controlled step — already true
  • [x] Deploy using blue/green — already true
  • [ ] Post-deployment smoke tests, rollout monitoring, stop/rollback on threshold — not automated; no monitoring exists yet to threshold against (Section 12)
  • [ ] Record approver/initiator, commit SHA/artifact ID/migration version — not recorded
  • [ ] Generate release notes — not automated
  • [ ] Notify both operators — not automated
  • [ ] Prevent concurrent production deploys — not enforced
  • [x] Documented manual/emergency deployment path — exists (it's the current default path)
  • [x] Documented rollback command — exists (IMAGE_TAG=<prev>)
  • [ ] Rollback tested before launch — not yet done, explicitly required by the checklist

Reminder — prod deploy is currently broken regardless of automation

Per Section 0: the production EC2 instance has no IAM instance profile, so push.sh prod fails outright today (InvalidInstanceId) even run manually. Fixing that (attach musehub-ec2-ssm to i-0855d6efe7fa1a49d) is a prerequisite for any production deploy, automated or not — it's real infrastructure work, not part of this doc-only pass, but flagged again here since it blocks literally everything in Section 11 regardless of automation progress.

File History 2 commits
sha256:bba4b69de173366aeb7d490d687ccffb6db9726374033addece89cf2b87642d8 docs: add production launch discovery report and infra laun… Sonnet 5 8 days ago
sha256:eb0928124669c933c0ef852bea1ad0c56649cf21bd7e9663c3b51004771b0591 docs: add MuseHub cloud identity/AWS operating model and Go… Sonnet 5 patch 9 days ago