feat: add static sites hosting gateway#208
Open
vigneshrajsb wants to merge 5 commits into
Open
Conversation
- Capped ZIP decompression by actual inflated bytes to prevent upload OOM bypasses. - Made object cleanup retryable by only marking rows deleted after storage deletion succeeds. - Closed gateway object streams on HEAD requests. - Added OpenAPI coverage for /api/v2/sites* and regenerated UI API types. - Verified create, fetch, HEAD, replace, extend, and delete end to end in Tilt.
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.
Summary
Adds a v2 static sites hosting flow to Lifecycle:
/api/v2/sitesAPIs for create, list, read, replace content, extend TTL, and soft delete.SiteandSiteVersionmodels plus a migration-seededsitesglobal config, disabled by default.ws-server.tsthat servesGET/HEADsite traffic from object storage by configured host parsing.Notes
The temporary planning doc and local test UI are intentionally not included in this PR.
Configuration
This PR seeds a
sitesrow inglobal_configand defaults it to disabled. Runtime site-hosting behavior is controlled there, so most values below can be changed without redeploying Lifecycle. The gateway component, wildcard ingress host, DNS/cert wiring, and object-store/IAM setup are still deploy-time infrastructure concerns.Example
global_config.configshape for keysites:{ "enabled": false, "domain": "sites.lifecycle.example.com", "port": null, "hostPrefix": "site", "ttl": { "enabled": true, "defaultDays": 7, "extensionDays": 7 }, "upload": { "maxUploadBytes": 10485760, "maxExtractedBytes": 10485760, "maxFiles": 500, "allowedExtensions": [ "html", "zip", "json", "md", "markdown", "txt", "css", "js", "mjs", "map", "csv", "xml", "svg", "png", "jpg", "jpeg", "gif", "webp", "avif", "ico", "webmanifest", "wasm", "woff", "woff2", "ttf", "otf", "pdf" ] }, "storage": { "backend": "minio", "bucket": "lifecycle-sites", "prefix": "sites", "region": "us-west-2", "endpoint": null, "forcePathStyle": true }, "cleanup": { "enabled": true, "intervalMinutes": 15 } }Option notes:
enabled: gates the v2 sites APIs and gateway host matching.domain,port,hostPrefix: generate and parse URLs ashttps://{hostPrefix}-{siteId}.{domain}; local dev can uselocalhostplus a forwarded port.ttl.enabled: when disabled, new sites do not get an expiration and the cleanup job does not expire hosted sites.upload: caps uploads and extracted ZIP content at 10 MiB by default; ZIP uploads must contain anindex.htmlat root or one top-level folder.storage: supportsminioands3. MinIO can create the bucket on demand; S3 expects the bucket and credentials/IAM to already be provisioned.cleanup: schedules expired-site cleanup whenenabled,ttl.enabled, andcleanup.enabledare all true. Cleanup soft-deletes DB rows and removes object-store prefixes.Deploy-time gateway options live in Helm values rather than
global_config:components.gateway.enabled: deploys the separate gateway process.components.gateway.deployment.replicaCount,resources,nodeSelector,tolerations, andextraEnv: size and schedule the gateway like the other Lifecycle components.components.gateway.service: controls the ClusterIP/service port.components.gateway.ingress: controls ingress class, annotations, paths, and the wildcard host, for example*.sites.lifecycle.example.com.LIFECYCLE_MODE=gatewayand need the same DB/object-store/global-config access as web/worker.Validation
Passed:
GET /api/healthon web and gateway returned200.POST /api/v2/sites.200./missing-routereturns404.404.pnpm run lintpnpm test -- src/server/lib/sitesws-server.tsgit diff --checkKnown repo/environment failures not introduced by this PR:
pnpm run ts-checkfails on existing repo-wide TypeScript errors outside the sites/gateway paths.pnpm testfails many suites before execution because this shell does not provideDATABASE_URL/ DB env; the new sites tests pass.