← Back to Pull requests

Run Cloud web and worker as node, and skip the cloud metadata detectors #3134

Closed
unknown closed this pull request without merging on Oct 23, 2026 00:31 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 23:18 UTC
Author

Fixes #2993.

Summary

Ployz Cloud's web and worker images now run as node (uid 1000), not root. They also stop probing cloud metadata servers on boot.

 FROM node AS runtime
+ENV OTEL_NODE_RESOURCE_DETECTORS=env,host,os,process,serviceinstance,container
-COPY .output / node_modules
+COPY --chmod=a+rX .output / node_modules     # pnpm's store can leave files owner-only
 RUN ln -sfn … && touch .env && node -p … > .ployz-version   # still root, at build time
 COPY drizzle/, scripts/check-schema.ts, src/server/schema-compatibility.ts
+USER node
 CMD node … --import ./scripts/check-schema.ts .output/server/index.mjs

The OpenTelemetry auto-instrumentation's default detectors include the Alibaba, AWS, Azure and GCP ones. On every boot they call a metadata address such as 169.254.169.254. Self-hosters saw that as unexpected outbound traffic. The image now names the six detectors that read only the local host and container.

Both Dockerfiles change: the root Dockerfile (self-host) and Dockerfile.cloud (built and published by CI). Dockerfile.cloud gains # syntax=docker/dockerfile:1 for the symbolic --chmod. The CI image smoke step now asserts uid ≠ 0 and the exact detector list.

This sits on top of #3109's schema guard. The guard's files are written as root at build time, and at runtime the guard only reads.

Evidence

  • Before: process.getuid() in the image is 0, and getResourceDetectors() includes AlibabaCloudEcsDetector … GcpDetector (all 10 cloud detectors).

  • After: I built the root Dockerfile locally from a clean git archive of this branch:
  • uid 1000 home /home/node
    ["EnvDetector","HostDetector","OSDetector","ProcessDetector","ServiceInstanceIdDetector","ContainerDetector"]
    version 0.3.1
    uid=1000(node) gid=1000(node)
    node --import ./scripts/check-schema.ts -> "DATABASE_URL is required to check schema compatibility" (the guard loads as node)
    

  • An earlier delegate built Dockerfile.cloud the same way and confirmed with tcpdump that the image sends nothing to 169.254.169.254 on boot.

  • CI's cloud smoke step runs the same assertions on Dockerfile.cloud.
  • Ops

    Hosted Cloud (np1): yes, this applies. Self-host compose and hosted Cloud both run ghcr.io/getployz/ployz-cloud, which CI builds from Dockerfile.cloud on every push to main. So np1's web and worker run as uid 1000 from the first image built after this merges.

  • Upgrade. Without a writable mount, nothing changes. The app writes only to /tmp and $HOME/.npm (/home/node, owned by node). A mount on web or worker that root wrote stays readable when its files are 644 or 755. A write into it fails with EACCES, and so does a read of a 600 file. The fix is a one-time chown -R 1000:1000 <path>, or user: "0" on that service until the chown is done. I can't see np1's compose (it lives in getployz/ops), so whether np1 mounts anything on web or worker is still open.

  • Rollback to a root image is safe. Root reads and writes everything, including files node created.

  • docker exec now enters as node. Maintenance that needs root uses docker exec -u 0.

  • No user: override without HOME. A compose user: with no passwd entry leaves HOME at /, and npm start then fails writing ~/.npm/_logs.

  • Detectors. OTEL_NODE_RESOURCE_DETECTORS=all brings back the cloud detectors. No Cloud code or doc reads cloud.* attributes, and np1 runs on Hetzner, where none of them matched anyway.

  • Builder. A symbolic --chmod needs BuildKit with Dockerfile frontend 1.14 or later. Both files pin docker/dockerfile:1. A legacy builder fails at build time, not at runtime.
  • Existing self-host installs: no manual step. dashboard/self-host/compose.yml mounts no volume on web or worker, only on postgres and redis, which keep their own images and users. Pulling the new tag and running docker compose up -d is enough.

    Bets

    None of the Engine bets in core/DESIGN.md are touched. This is image packaging only, with no schema, RPC or stored-format change.

    Merge Danger

    Door: two-way. Revert the PR and the images run as root again.

    Blast Radius: deploy. A host whose web or worker writes to a root-owned mount fails on its first write after upgrading. The Ops notes above cover it.

    Diff: 538 lines (+403 / -135) across 6 files Reviewer: nick-potts Review duration: 72m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 538 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.376
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3134"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.9% (MEDIUM) · Higher = larger blast radius
    47.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.7% · Safe to merge
    20.7%
    Repository