Skip to content

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

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

pulkitxm merged 5 commits into
mainfrom
deploy-eks-orbit-namespace

Conversation

@pulkitxm

Copy link
Copy Markdown
Member

Adds container images, Kubernetes manifests and the CodeBuild pipeline to run web, realtime and mcp in the orbit namespace, and makes S3 the only object store.

pulkitxm added 3 commits July 23, 2026 16:48
Drop the local filesystem driver so uploads have a single source. The S3
driver now omits static credentials when none are configured, which lets
the AWS SDK pick up the pod role in EKS, and local development points the
same driver at minio.

Uploads previously only reached 'ready' through the local write path, so
add an explicit completion endpoint that confirms the object landed in S3
before flipping the status. Downloads stay behind the permission check and
redirect to a presigned URL that pins content type and disposition.

Anchor the storage ignore rule to the repository root so it stops matching
the storage source directory.
Build each app from a turbo-pruned workspace. Web emits a standalone
Next.js server, realtime and mcp ship a single esbuild bundle. Adds the
unauthenticated health endpoint the load balancer probes.
Manifests for the orbit namespace covering web, realtime, mcp and Redis,
routed through one hostname on the shared load balancer. Pods reach S3
through an IRSA service account rather than static keys, and schema changes
run as an explicit job rather than on every build.

This repository is public, so no manifest carries an account id, ARN or
address. apply.sh resolves those from the caller's AWS credentials and
substitutes them before handing the result to kubectl.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change transitions storage to S3, adds upload completion and signed-download handling, introduces Docker images and Next.js standalone output, defines EKS resources and ingress routing, and adds CodeBuild, deployment scripts, migration workflows, and local MinIO bucket initialization.

Changes

Storage and attachment flow

Layer / File(s) Summary
S3 storage contract and key safety
packages/services/src/storage/*
Storage exports and configuration now target S3, support ambient credentials and signed-download options, and validate storage keys with updated tests.
Attachment completion and downloads
apps/web/src/app/api/attachments/..., apps/web/src/app/api/files/..., apps/web/src/features/docs/upload.ts, apps/web/src/app/api/health/route.ts
Uploads are completed through a validated API route, downloads redirect to time-limited storage URLs, and a dynamic web health endpoint is added.

Container and cluster delivery

Layer / File(s) Summary
Service image packaging
.dockerignore, apps/*/Dockerfile, packages/db/Dockerfile, apps/web/next.config.ts
Multi-stage pnpm, Turbo, and Doppler images are added for web, realtime, MCP, and database services; web builds use standalone output.
EKS runtime resources
k8s/*.yaml
Namespace, service account, Redis, application deployments, services, probes, autoscaling, disruption budgets, ingress routes, and migration resources are defined.
Image publishing and cluster deployment
buildspec.yml, k8s/apply.sh, k8s/migrate.sh, k8s/README.md
CodeBuild builds and pushes images, updates EKS deployments, waits for rollouts, and documents or automates manifest application and migrations.

Local development configuration

Layer / File(s) Summary
MinIO initialization and ignore rules
.gitignore, docker-compose.yml
Root storage ignores are narrowed and a helper service creates the local MinIO upload bucket idempotently.

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

Sequence Diagram(s)

sequenceDiagram
  participant CodeBuild
  participant ECR
  participant EKS
  CodeBuild->>ECR: Build and push tagged service images
  CodeBuild->>EKS: Update web, realtime, and MCP images
  EKS-->>CodeBuild: Report rollout completion or failure
Loading

Possibly related PRs

  • Noveum/orbit#5: Both changes modify the services storage layer and its local/S3 driver exports.
🚥 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 changeset and mentions the deployment pipeline, Kubernetes manifests, and S3-only storage.
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-eks-orbit-namespace

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)
apps/mcp/Dockerfile

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

apps/realtime/Dockerfile

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

apps/web/Dockerfile

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

  • 10 others
🔧 Trivy (0.72.0)

Trivy execution failed: 2026-07-23T11:56:07Z FATAL Fatal error run error: fs scan error: scan error: scan failed: failed analysis: post analysis error: post analysis error: cloudformation scan error: fs filter error: fs filter error: walk error range error: stat packages/services/doctor.config.json: no such file or directory: range error: stat packages/services/doctor.config.json: no such file or directory


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

pulkitxm added 2 commits July 23, 2026 16:50
REALTIME_INTERNAL_TOKEN is referenced nowhere in the code, so drop it.
Resend is not optional: passwords are disabled and magic link is the only
way to create a session, so record that and the social callback shape.
RDS runs with rds.force_ssl=1, so plaintext connections are rejected.
Mount the Amazon RDS certificate authority from a ConfigMap and point
NODE_EXTRA_CA_CERTS at it, so the connection is verified rather than
merely encrypted. Keeping the bundle out of the images means rotating it
is an apply instead of a rebuild.

migrate.sh read the job status immediately after following the logs and
raced the controller, reporting failure for a migration that had actually
applied. Wait on the completion condition instead.
@pulkitxm
pulkitxm merged commit 2c7387a into main Jul 23, 2026
3 of 4 checks passed
@pulkitxm
pulkitxm deleted the deploy-eks-orbit-namespace branch July 23, 2026 12:10

@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: 10

🧹 Nitpick comments (4)
k8s/README.md (1)

65-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove inline comments from the shell example.

The surrounding prose already explains these commands, so the trailing shell comments are unnecessary.

As per coding guidelines, “Do not add comments in code, except functional directives such as @ts-*, biome-ignore, eslint-*, and /*! license */.”

Proposed cleanup
-./k8s/apply.sh --render        # print the resolved manifests, change nothing
-./k8s/apply.sh --dry-run       # server side dry run
-./k8s/apply.sh                 # apply for real
+./k8s/apply.sh --render
+./k8s/apply.sh --dry-run
+./k8s/apply.sh
🤖 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 `@k8s/README.md` around lines 65 - 69, Remove the trailing inline comments from
the three k8s/apply.sh command examples, leaving each command otherwise
unchanged.

Source: Coding guidelines

apps/web/src/features/docs/upload.ts (1)

47-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the exported FILE_ROUTE constant instead of hardcoding /api/files.

packages/services/src/storage/index.ts now exports FILE_ROUTE = '/api/files' specifically for this kind of consumption; hardcoding the literal here duplicates it and can silently drift if the route changes.

♻️ Proposed fix
+import { FILE_ROUTE } from '`@orbit/services/storage`';
...
   return {
     fileName: file.name,
     contentType,
-    url: `/api/files/${presigned.upload.key.split('/').map(encodeURIComponent).join('/')}`,
+    url: `${FILE_ROUTE}/${presigned.upload.key.split('/').map(encodeURIComponent).join('/')}`,
   };
🤖 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 `@apps/web/src/features/docs/upload.ts` around lines 47 - 51, Update the return
object in the upload flow to use the exported FILE_ROUTE constant when
constructing the presigned file URL, replacing the hardcoded “/api/files”
segment while preserving the existing key encoding and path joining.
k8s/00-namespace.yaml (1)

8-16: 🔒 Security & Privacy | 🔵 Trivial | 💤 Low value

Consider disabling default SA token automount.

orbit-app doesn't appear to need direct Kubernetes API access; only the IRSA-injected AWS token is required. Setting automountServiceAccountToken: false reduces unnecessary token exposure to pods without affecting IRSA (which uses a separate projected volume).

🤖 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 `@k8s/00-namespace.yaml` around lines 8 - 16, Update the orbit-app
ServiceAccount manifest to set automountServiceAccountToken to false, while
preserving its existing metadata and IRSA role annotation.
k8s/02-web.yaml (1)

57-91: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

No container-level securityContext on any of the three app Deployments. k8s/01-redis.yaml sets runAsNonRoot, runAsUser, and runAsGroup, but orbit-web, orbit-realtime, and orbit-mcp set none, leaving them to run with whatever default (likely root) the images use.

  • k8s/02-web.yaml#L57-L91: add a container/pod securityContext (runAsNonRoot: true, allowPrivilegeEscalation: false, capabilities: {drop: ["ALL"]}, readOnlyRootFilesystem where feasible) to orbit-web.
  • k8s/03-realtime.yaml#L57-L87: same hardening for orbit-realtime.
  • k8s/04-mcp.yaml#L48-L78: same hardening for orbit-mcp.
🤖 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 `@k8s/02-web.yaml` around lines 57 - 91, Harden the container security settings
for orbit-web in k8s/02-web.yaml (lines 57-91), orbit-realtime in
k8s/03-realtime.yaml (lines 57-87), and orbit-mcp in k8s/04-mcp.yaml (lines
48-78) by adding securityContext configuration with runAsNonRoot: true,
allowPrivilegeEscalation: false, and all Linux capabilities dropped; enable
readOnlyRootFilesystem where each application supports it.
🤖 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 `@apps/web/Dockerfile`:
- Around line 44-48: Add executable CI deployment coverage for the service
images represented by the Docker build, including building and starting each
image, verifying health and routing behavior, and rendering then validating the
migration manifest. Ensure the checks exercise runtime copy paths, required
modules, and image placeholder resolution rather than relying only on static
configuration review.

In `@apps/web/src/app/api/attachments/`[id]/complete/route.ts:
- Around line 22-26: Update the size validation in the completion flow around
createStorageDriver().stat and the stored/record size checks to reject any
mismatch between stored.size and record.size, not only oversized objects.
Preserve the existing not-found and oversized-upload errors while ensuring
smaller objects cannot be marked ready with a stale registered size.
- Around line 28-32: Update the attachment completion flow around the
schema.attachment update and returned updated record to increment sync_id and
publish the corresponding SyncAction after marking the attachment ready. Ensure
the action contains the completed attachment change so realtime clients receive
the update, while preserving the existing database update behavior.

In `@apps/web/src/features/docs/upload.ts`:
- Around line 43-46: Add coverage in docs.test.ts for uploadDocFile that
verifies the completion POST is sent to /api/attachments/:id/complete with the
expected method and attachment ID, so the test fails if this request is removed
or broken.

In `@k8s/01-redis.yaml`:
- Around line 47-52: Remove the Redis password from process arguments in the
Redis command and readiness/liveness probes. Update the Redis startup
configuration around the args block to source authentication from a mounted
config file, and change the redis-cli probes to use the REDISCLI_AUTH
environment variable instead of the -a option while preserving their existing
checks.

In `@k8s/06-migrate-job.yaml`:
- Around line 26-27: Update the migration Job image reference in the manifest to
use the same rendered immutable release tag as the application rollout instead
of the mutable latest tag, while preserving the existing ECR registry and image
name.

In `@k8s/apply.sh`:
- Around line 29-36: Update the ACM certificate lookup that initializes
ACM_CERTIFICATE_ARN to select an ISSUED certificate whose primary domain or SANs
cover ORBIT_HOST, including wildcard domains, rather than matching only
CERT_DOMAIN. Preserve explicit ACM_CERTIFICATE_ARN values, and fail with the
existing error when no suitable certificate is found.

In `@k8s/migrate.sh`:
- Around line 27-30: Reorder the migration flow so the 180-second kube wait for
Job completion starts before the kube logs --follow command. Preserve the
existing log streaming and completion-status handling, but ensure a stuck log
stream cannot prevent the completion timeout from running.

In `@k8s/README.md`:
- Around line 76-80: Update all standalone kubectl examples in k8s/README.md at
lines 76-80, 104-106, and 214-219 to pass --server="$KUBE_SERVER", or
consistently use the wrapper invoked by apply.sh and migrate.sh, so each command
targets the configured Kubernetes server.

In `@packages/db/Dockerfile`:
- Around line 21-30: Add a non-root user in the Dockerfile’s runner stage and
switch to it with a USER directive before CMD, ensuring the existing
Doppler-wrapped pnpm push command continues to run under that user.

---

Nitpick comments:
In `@apps/web/src/features/docs/upload.ts`:
- Around line 47-51: Update the return object in the upload flow to use the
exported FILE_ROUTE constant when constructing the presigned file URL, replacing
the hardcoded “/api/files” segment while preserving the existing key encoding
and path joining.

In `@k8s/00-namespace.yaml`:
- Around line 8-16: Update the orbit-app ServiceAccount manifest to set
automountServiceAccountToken to false, while preserving its existing metadata
and IRSA role annotation.

In `@k8s/02-web.yaml`:
- Around line 57-91: Harden the container security settings for orbit-web in
k8s/02-web.yaml (lines 57-91), orbit-realtime in k8s/03-realtime.yaml (lines
57-87), and orbit-mcp in k8s/04-mcp.yaml (lines 48-78) by adding securityContext
configuration with runAsNonRoot: true, allowPrivilegeEscalation: false, and all
Linux capabilities dropped; enable readOnlyRootFilesystem where each application
supports it.

In `@k8s/README.md`:
- Around line 65-69: Remove the trailing inline comments from the three
k8s/apply.sh command examples, leaving each command otherwise unchanged.
🪄 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: 227e2879-3c61-41d7-94fa-91f1f37513ed

📥 Commits

Reviewing files that changed from the base of the PR and between e222cf0 and 8820b54.

📒 Files selected for processing (30)
  • .dockerignore
  • .env.example
  • .gitignore
  • 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/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/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 apps/web/Dockerfile Resolved
Comment thread apps/web/src/features/docs/upload.ts Resolved
Comment thread k8s/01-redis.yaml Resolved
Comment thread k8s/06-migrate-job.yaml Resolved
Comment thread k8s/apply.sh Resolved
Comment thread k8s/migrate.sh Resolved
Comment thread k8s/README.md Resolved
Comment thread packages/db/Dockerfile Resolved
pulkitxm added a commit that referenced this pull request Jul 23, 2026
pulkitxm added a commit that referenced this pull request Jul 23, 2026
Adds container images, Kubernetes manifests and the CodeBuild pipeline for the orbit namespace, and makes S3 the only object store with pods reaching it through an IRSA service account. Re-lands #22 with every review finding addressed.
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