Repository navigation
feat(deploy): run Orbit on EKS with S3-backed uploads - #22
Conversation
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.
📝 WalkthroughWalkthroughThe 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. ChangesStorage and attachment flow
Container and cluster delivery
Local development configuration
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
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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/DockerfileTraceback (most recent call last): apps/realtime/DockerfileTraceback (most recent call last): apps/web/DockerfileTraceback (most recent call last):
🔧 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 |
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.
There was a problem hiding this comment.
Actionable comments posted: 10
🧹 Nitpick comments (4)
k8s/README.md (1)
65-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove 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 winUse the exported
FILE_ROUTEconstant instead of hardcoding/api/files.
packages/services/src/storage/index.tsnow exportsFILE_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 valueConsider disabling default SA token automount.
orbit-appdoesn't appear to need direct Kubernetes API access; only the IRSA-injected AWS token is required. SettingautomountServiceAccountToken: falsereduces 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 winNo container-level
securityContexton any of the three app Deployments.k8s/01-redis.yamlsetsrunAsNonRoot,runAsUser, andrunAsGroup, butorbit-web,orbit-realtime, andorbit-mcpset none, leaving them to run with whatever default (likely root) the images use.
k8s/02-web.yaml#L57-L91: add a container/podsecurityContext(runAsNonRoot: true,allowPrivilegeEscalation: false,capabilities: {drop: ["ALL"]},readOnlyRootFilesystemwhere feasible) toorbit-web.k8s/03-realtime.yaml#L57-L87: same hardening fororbit-realtime.k8s/04-mcp.yaml#L48-L78: same hardening fororbit-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
📒 Files selected for processing (30)
.dockerignore.env.example.gitignoreapps/mcp/Dockerfileapps/realtime/Dockerfileapps/web/Dockerfileapps/web/next.config.tsapps/web/src/app/api/attachments/[id]/complete/route.tsapps/web/src/app/api/files/[...key]/route.tsapps/web/src/app/api/health/route.tsapps/web/src/features/docs/upload.tsbuildspec.ymldocker-compose.ymlk8s/00-namespace.yamlk8s/01-redis.yamlk8s/02-web.yamlk8s/03-realtime.yamlk8s/04-mcp.yamlk8s/05-ingress.yamlk8s/06-migrate-job.yamlk8s/README.mdk8s/apply.shk8s/migrate.shpackages/db/Dockerfilepackages/services/src/storage/index.tspackages/services/src/storage/key.tspackages/services/src/storage/local.tspackages/services/src/storage/s3.tspackages/services/src/storage/storage.test.tspackages/services/src/storage/types.ts
💤 Files with no reviewable changes (2)
- .env.example
- packages/services/src/storage/local.ts
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.
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.