mirror of
https://github.com/different-ai/openwork
synced 2026-04-25 17:15:34 +02:00
3.4 KiB
3.4 KiB
Den Service
Control plane for hosted workers. Provides Better Auth, worker CRUD, and provisioning hooks.
Quick start
pnpm install
cp .env.example .env
pnpm dev
Environment
DATABASE_URLMySQL connection URLBETTER_AUTH_SECRET32+ char secretBETTER_AUTH_URLbase URL for auth callbacksPORTserver portCORS_ORIGINScomma-separated listPROVISIONER_MODEstuborrenderWORKER_URL_TEMPLATEtemplate string with{workerId}RENDER_API_BASERender API base URL (defaulthttps://api.render.com/v1)RENDER_API_KEYRender API key (required forPROVISIONER_MODE=render)RENDER_OWNER_IDRender workspace owner id (required forPROVISIONER_MODE=render)RENDER_WORKER_REPOrepository URL used to create worker servicesRENDER_WORKER_BRANCHbranch used for worker servicesRENDER_WORKER_ROOT_DIRrenderrootDirfor worker servicesRENDER_WORKER_PLANRender plan for worker servicesRENDER_WORKER_REGIONRender region for worker servicesRENDER_WORKER_OPENWORK_VERSIONopenwork-orchestratornpm version installed in workersRENDER_WORKER_NAME_PREFIXservice name prefixRENDER_PROVISION_TIMEOUT_MSmax time to wait for deploy to become liveRENDER_HEALTHCHECK_TIMEOUT_MSmax time to wait for worker health checksRENDER_POLL_INTERVAL_MSpolling interval for deploy + health checksPOLAR_FEATURE_GATE_ENABLEDenable cloud-worker paywall (trueorfalse)POLAR_API_BASEPolar API base URL (defaulthttps://api.polar.sh)POLAR_ACCESS_TOKENPolar organization access token (required when paywall enabled)POLAR_PRODUCT_IDPolar product ID used for checkout sessions (required when paywall enabled)POLAR_BENEFIT_IDPolar benefit ID required to unlock cloud workers (required when paywall enabled)POLAR_SUCCESS_URLredirect URL after successful checkout (required when paywall enabled)POLAR_RETURN_URLreturn URL shown in checkout (required when paywall enabled)
Auth setup (Better Auth)
Generate Better Auth schema (Drizzle):
npx @better-auth/cli@latest generate --config src/auth.ts --output src/db/better-auth.schema.ts --yes
Apply migrations:
pnpm db:generate
pnpm db:migrate
API
GET /healthGET /demo web app (sign-up + auth + worker launch)GET /v1/meGET /v1/workers(list recent workers for signed-in user/org)POST /v1/workers- Cloud launches return
202quickly with workerstatus=provisioningand continue provisioning asynchronously. - Returns
402 payment_requiredwith Polar checkout URL when paywall is enabled and entitlement is missing.
- Cloud launches return
GET /v1/workers/:id- Includes latest instance metadata when available.
POST /v1/workers/:id/tokens
CI deployment (dev == prod)
The workflow .github/workflows/deploy-den.yml updates Render env vars and deploys the service on every push to dev when this service changes.
Required GitHub Actions secrets:
RENDER_API_KEYRENDER_DEN_CONTROL_PLANE_SERVICE_IDRENDER_OWNER_IDDEN_DATABASE_URLDEN_BETTER_AUTH_SECRET
Optional GitHub Actions variable:
DEN_RENDER_WORKER_PLAN(defaults tostandard)DEN_RENDER_WORKER_OPENWORK_VERSION(defaults to0.11.113)DEN_POLAR_FEATURE_GATE_ENABLED(true/false, defaults tofalse)DEN_POLAR_API_BASE(defaults tohttps://api.polar.sh)DEN_POLAR_SUCCESS_URL(defaults tohttps://app.openwork.software)DEN_POLAR_RETURN_URL(defaults toDEN_POLAR_SUCCESS_URL)