Skip to content

feat(deploy): run Orbit on EKS with S3-backed uploads - #23

Merged
pulkitxm merged 6 commits into
mainfrom
deploy-orbit-eks
Jul 23, 2026
Merged

pulkitxm merged 6 commits into
mainfrom
deploy-orbit-eks

Conversation

@pulkitxm

Copy link
Copy Markdown
Member

Re-lands the reverted deploy work with every CodeRabbit finding from #22 addressed, plus a CLAUDE.md rule that no PR merges with an unresolved review thread.

pulkitxm added 5 commits July 23, 2026 17:53
Green CI is not enough on its own. Record that a pull request waits for
the review to finish, and that each thread ends either with a fix or with
a reply saying why the finding does not apply.
Completion only rejected oversized uploads, so an object smaller than the
client declared kept the larger registered size and misled anything
reading attachment.size. Record the size storage actually reports.

The route also wrote to Postgres without bumping sync_id or publishing a
SyncAction, so realtime clients never saw an attachment become ready.
Move that into a core service that allocates the sync id and emits the
action in the same transaction, scoped to the parent doc or issue.

Cover the upload path with tests that fail if the completion request is
removed.
Redis took its password through argv, where any process listing inside the
container could read it. Write a config file at startup instead, and let
the probes authenticate through REDISCLI_AUTH.

The migration job ran the mutable latest tag, so it could apply a
different release than the one being rolled out. Pin it to the tag the web
deployment is actually running, and refuse to migrate from a mutable tag.

The migration image ran as root despite holding database and token access,
so give it a non-root user.

apply.sh matched only a certificate's primary domain and could pick one
that does not cover the host. Match subject alternative names, restrict to
issued certificates, and say so when nothing matches.

migrate.sh started its timeout only after the log stream ended, so a stuck
job waited forever. Bound the wait and stop following logs when it ends.

Pass the bastion server to the kubectl examples in the README so they work
in the flow the same document describes.
Static review cannot catch a broken copy path, a missing runtime module or
a placeholder that never got substituted. Build all four images, boot the
web image and require it to serve its health endpoint, assert the
migration image is not root, and render every manifest to check no
placeholder survives and the result validates.

The web build required a Doppler token, which made the image impossible to
build without production credentials. Fall back to a clearly labelled
placeholder build when no token is mounted.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 86ab1964-430b-44a1-ab22-703fd0472e27

📥 Commits

Reviewing files that changed from the base of the PR and between c619dba and d126756.

📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • apps/web/src/app/api/attachments/[id]/complete/route.ts
  • apps/web/src/app/api/attachments/presign/route.ts
  • apps/web/src/app/api/files/[...key]/route.ts
  • k8s/06-migrate-job.yaml
  • k8s/migrate.sh
  • packages/services/src/storage/index.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • k8s/06-migrate-job.yaml
  • apps/web/src/app/api/attachments/[id]/complete/route.ts
  • apps/web/src/app/api/files/[...key]/route.ts
  • k8s/migrate.sh
  • .github/workflows/ci.yml

📝 Walkthrough

Walkthrough

This PR makes object storage S3-only, adds attachment completion validation, introduces Docker builds for application services, and adds CI and EKS deployment infrastructure with Kubernetes manifests, rendering scripts, migration execution, and operational documentation.

Changes

S3 storage and attachment uploads

Layer / File(s) Summary
S3 storage contract and URL handling
packages/services/src/storage/*, .env.example, docker-compose.yml
Storage uses S3 with optional ambient credentials, validates keys, and generates download URLs with content type and disposition overrides. MinIO bucket initialization is added.
Attachment completion workflow
packages/core/src/content/attachment-service.ts, apps/web/src/app/api/attachments/*, apps/web/src/features/docs/upload.ts, apps/web/src/app/api/files/[...key]/route.ts
Uploads now call a completion endpoint that verifies stored size, marks attachments ready, publishes sync actions, and serves files through signed URL redirects.
Upload and storage test coverage
apps/web/src/features/docs/docs.test.ts, packages/services/src/storage/storage.test.ts
Tests cover presign-to-completion uploads, completion failures, safe keys, and S3 credential configurations.

Container and delivery pipeline

Layer / File(s) Summary
Service image builds and runtime packaging
apps/*/Dockerfile, packages/db/Dockerfile, apps/web/next.config.ts, apps/web/src/app/api/health/route.ts, .dockerignore
Multi-stage images build services with Turbo and pnpm, run under non-root users with Doppler, and expose health endpoints; Next.js standalone output is enabled.
Image and manifest CI validation
.github/workflows/ci.yml, buildspec.yml, .gitignore, CLAUDE.md
CI and CodeBuild build and validate images, rendered Kubernetes YAML, shell scripts, and deployment rollouts.

EKS runtime deployment

Layer / File(s) Summary
Namespace, identity, and Redis foundation
k8s/00-namespace.yaml, k8s/01-redis.yaml, docker-compose.yml
Defines the orbit namespace, IRSA service account, persistent authenticated Redis StatefulSet, and MinIO bucket initialization.
Application services and ingress routing
k8s/02-web.yaml, k8s/03-realtime.yaml, k8s/04-mcp.yaml, k8s/05-ingress.yaml
Adds application Services, Deployments, probes, resource policies, web autoscaling, disruption budgets, and shared ALB routes.
Manifest rendering and migration operations
k8s/06-migrate-job.yaml, k8s/apply.sh, k8s/migrate.sh, k8s/README.md
Adds manifest rendering and application, immutable-tag migration Jobs, completion waiting, and EKS deployment documentation.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant WebAPI
  participant Storage
  participant AttachmentService
  participant Realtime
  Browser->>WebAPI: request presigned upload
  WebAPI-->>Browser: return presigned URL
  Browser->>Storage: upload file
  Browser->>WebAPI: request attachment completion
  WebAPI->>Storage: verify object and size
  WebAPI->>AttachmentService: mark attachment ready
  AttachmentService->>Realtime: publish attachment update
  WebAPI-->>Browser: return completed attachment
Loading

Possibly related PRs

  • Noveum/orbit#5: Introduced the storage implementation refactored by this PR.
  • Noveum/orbit#22: Contains closely related S3 storage and attachment upload changes.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: deploying Orbit on EKS with S3-backed uploads.
Description check ✅ Passed The description is directly related to the deployment and review-thread changes in the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch deploy-orbit-eks

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
.github/workflows/ci.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

k8s/06-migrate-job.yaml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (3)
packages/services/src/storage/s3.ts (2)

14-21: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Partial S3 credentials are silently dropped rather than rejected.

If only accessKeyId or only secretAccessKey is supplied directly to S3StorageDriver (bypassing createStorageDriver's "both or neither" guard), explicitCredentials becomes {} and the client silently falls back to ambient credentials instead of erroring. The invariant is enforced only at the factory level (index.ts), not in s3ConfigSchema itself, so any other caller of S3StorageDriver directly (as the test suite already does) can bypass it.

🛡️ Suggested fix: enforce the invariant in the schema
 export const s3ConfigSchema = z.object({
   bucket: z.string().min(1),
   region: z.string().min(1).default('us-east-1'),
   endpoint: z.string().url().optional(),
   accessKeyId: z.string().min(1).optional(),
   secretAccessKey: z.string().min(1).optional(),
   forcePathStyle: z.boolean().optional(),
-});
+}).refine(
+  (config) => (config.accessKeyId === undefined) === (config.secretAccessKey === undefined),
+  { message: 'Set both accessKeyId and secretAccessKey, or neither.' },
+);

Also applies to: 34-44

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/services/src/storage/s3.ts` around lines 14 - 21, Update
s3ConfigSchema to reject configurations where exactly one of accessKeyId or
secretAccessKey is provided, while continuing to accept both credentials or
neither. Enforce this invariant at schema validation so direct S3StorageDriver
callers cannot silently fall back to ambient credentials; preserve the existing
field validation and defaults.

17-17: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use z.url() here. z.string().url() is deprecated in Zod v4 and will be removed in a future major version.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/services/src/storage/s3.ts` at line 17, Update the endpoint schema
to use Zod v4’s z.url() validator instead of the deprecated z.string().url()
chain, while preserving its optional behavior.
packages/core/src/content/attachment-service.ts (1)

17-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing direct test coverage for markAttachmentReady/findAttachmentForOrganization.

docs.test.ts only exercises this indirectly through the client-side upload flow (mocked fetch); none of the reviewed files test the transactional core logic itself (org-scoped lookup, syncId allocation, SyncAction scope construction for doc vs. issue parents). As per coding guidelines, "Every feature must include tests that would fail if the feature broke."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/content/attachment-service.ts` around lines 17 - 70, The
attachment service lacks direct tests for findAttachmentForOrganization and
markAttachmentReady. Add focused tests covering organization-scoped lookup,
not-found behavior, transactional syncId allocation and update, and SyncAction
scope construction for both doc and issue parent types, using mocks or fixtures
consistent with the existing test setup.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 119-129: Update the actions/checkout@v5 step in the CI workflow to
set persist-credentials to false, ensuring the GitHub token is not retained for
subsequent build steps.

In `@apps/web/src/app/api/files/`[...key]/route.ts:
- Around line 38-42: Cache a single module-level storage driver created by
createStorageDriver() and reuse it across requests. In
apps/web/src/app/api/files/[...key]/route.ts lines 38-42, replace the inline
factory call with the cached instance for getUrl; apply the same cached instance
in apps/web/src/app/api/attachments/[id]/complete/route.ts line 15 for stat.

In `@k8s/06-migrate-job.yaml`:
- Around line 9-11: Add activeDeadlineSeconds to the Kubernetes Job spec
alongside backoffLimit and ttlSecondsAfterFinished, setting it to the migration
timeout used by migrate.sh. Reuse the existing JOB_TIMEOUT substitution
mechanism, such as the __JOB_TIMEOUT__ placeholder, so the server-side Job
deadline stays synchronized with the script timeout.

In `@k8s/migrate.sh`:
- Around line 21-22: Update the AWS_ACCOUNT_ID initialization flow in migrate.sh
to mirror the validation guard used by apply.sh: reject empty or "None" account
IDs before constructing ECR_REGISTRY, and fail with the same clear error
behavior. Ensure invalid credentials cannot produce a registry value beginning
with "None.dkr.ecr".

---

Nitpick comments:
In `@packages/core/src/content/attachment-service.ts`:
- Around line 17-70: The attachment service lacks direct tests for
findAttachmentForOrganization and markAttachmentReady. Add focused tests
covering organization-scoped lookup, not-found behavior, transactional syncId
allocation and update, and SyncAction scope construction for both doc and issue
parent types, using mocks or fixtures consistent with the existing test setup.

In `@packages/services/src/storage/s3.ts`:
- Around line 14-21: Update s3ConfigSchema to reject configurations where
exactly one of accessKeyId or secretAccessKey is provided, while continuing to
accept both credentials or neither. Enforce this invariant at schema validation
so direct S3StorageDriver callers cannot silently fall back to ambient
credentials; preserve the existing field validation and defaults.
- Line 17: Update the endpoint schema to use Zod v4’s z.url() validator instead
of the deprecated z.string().url() chain, while preserving its optional
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cc186147-b40c-486b-b23b-aad98e1b7acc

📥 Commits

Reviewing files that changed from the base of the PR and between 59f8784 and c619dba.

📒 Files selected for processing (35)
  • .dockerignore
  • .env.example
  • .github/workflows/ci.yml
  • .gitignore
  • CLAUDE.md
  • apps/mcp/Dockerfile
  • apps/realtime/Dockerfile
  • apps/web/Dockerfile
  • apps/web/next.config.ts
  • apps/web/src/app/api/attachments/[id]/complete/route.ts
  • apps/web/src/app/api/files/[...key]/route.ts
  • apps/web/src/app/api/health/route.ts
  • apps/web/src/features/docs/docs.test.ts
  • apps/web/src/features/docs/upload.ts
  • buildspec.yml
  • docker-compose.yml
  • k8s/00-namespace.yaml
  • k8s/01-redis.yaml
  • k8s/02-web.yaml
  • k8s/03-realtime.yaml
  • k8s/04-mcp.yaml
  • k8s/05-ingress.yaml
  • k8s/06-migrate-job.yaml
  • k8s/README.md
  • k8s/apply.sh
  • k8s/migrate.sh
  • packages/core/src/content/attachment-service.ts
  • packages/core/src/index.ts
  • packages/db/Dockerfile
  • packages/services/src/storage/index.ts
  • packages/services/src/storage/key.ts
  • packages/services/src/storage/local.ts
  • packages/services/src/storage/s3.ts
  • packages/services/src/storage/storage.test.ts
  • packages/services/src/storage/types.ts
💤 Files with no reviewable changes (2)
  • .env.example
  • packages/services/src/storage/local.ts

Comment thread .github/workflows/ci.yml Resolved
Comment thread k8s/06-migrate-job.yaml Resolved
Comment thread k8s/migrate.sh Resolved
Every request built a fresh S3 client, re-parsing config and rebuilding
the credential chain. Under IRSA that can mean an STS round trip on the
download and upload paths, so cache one driver and share it.

migrate.sh only bounded its own wait, leaving a hung job running and
letting a retry start a second migration against the same schema. Give
the job a deadline that fires before the script stops waiting, and refuse
to start when one is already active. Validate the resolved account id
rather than building a broken registry reference from it.

Drop the persisted git credential from the image job, which never pushes.
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.

1 participant