返回资讯中心
外部精选
软件工程
#开发者实时流

launchroom:面向少量服务器的自托管 PaaS 开源项目

来源标题:How launchroom works: a self-hosted PaaS for one or a few servers

开发者 vantezzen 开源了 launchroom,一个面向一两台小 VPS 的自托管 PaaS 平台。它由平台自身负责构建服务器、多服务器和框架构建,服务器可分别承担 build、runtime、edge 三种角色,并通过 WireGuard 私有网络传输镜像。

Hacker News 最新bennett_dev2026/11/17 · 今天30 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

I run my side projects on two to three small VPSs. For a while I used self-hosted deployment tools for them, and they all ended up feeling like a dashboard around Docker rather than a managed platform. Deploying a single app on a single server worked well, however everything beyond that was manual:

launchroom is my attempt at the platform I wanted: build servers, multiple servers and framework builds handled by the platform itself, on hardware I own - kind of a “managed PaaS” feeling, but self-hosted. It's open source at https://github.com/vantezzen/launchroom.

This post goes through how the internals work and why they're designed the way they are.

Each server can have different “roles”: build, runtime and edge. With one server, that server has all of them. With more servers, you can for example build on a machine at home and run on two VPSs, both of which serve traffic.

signed desired state

signed desired state

signed desired state

private mesh (WireGuard)

images over the mesh

Dashboard

launchroomdserver A: edge + runtime

launchroomdserver B: runtime

launchroomdhome server: build

Installation

One thing that also annoyed me was that many self-hosting dashboards kind of take over your whole server. The actual repo code they pulled is somewhere deep in /etc or /var, with various background services and containers started somewhere.

Instead for launchroom I decided that all core containers are in just a single transparent compose project, all the local files are simply in a ./launchroom directory and all containers that launchroom creates get a launchroom.managed=true label. This way, you can continue using your server for everything else without some hidden connections and you can just stop all those containers and remove that one folder to install it.

For projects I didn’t want to manually fiddle with Docker compose files or special syntax, so I got inspired by Railway to create a project canvas instead.

In the canvas you can simply add new nodes and connect them visually to connect their network and exchange the credentials.

The UI uses React Flow which was super nice to work with.

An early decision I made looking at other self-hosting codes, was that the dashboard can't run commands on servers. There is no SSH, no command endpoint and launchroomd listens on no public port. My reasoning was that the dashboard is a web app holding full power, and if it could run commands on every server, any bug in it would be root on all of them.

Instead, the dashboard build a desired state document per server, the NodeState. It describes everything the server should run: networks, volumes, containers, routes and firewall rules. launchroomd fetches it, verifies it and converges the server towards it. A shortened example:

{ "kind": "NodeState", "version": 1842, // monotonic per server; older versions are rejected "issuedAt": "2026-10-17T12:00:00Z", "workloads": [{ "id": "wl_…", "image": "127.0.0.1:5000/apps/svc_…@sha256:…", "args": ["node", "server.js"], // argv, never a shell string "env": { "sealed": "<crypto_box_seal(json env, daemon x25519)>" }, "health": { "type": "http", "path": "/", "expectStatus": "2xx-3xx" }, "role": "serving" // serving | draining }], "routes": [{ "hosts": ["shop.com"], "upstreams": [{ "workload": "wl_…", "port": 3000 }] }] }

All connections go from launchroomd to the dashboard. The dashboard signs the exact response bytes with Ed25519, and launchroomd checks the signature before parsing the JSON. This avoids having to canonicalise JSON for signing. For the same reason, launchroomd stores the original bytes and signature on disk instead of its parsed copy, and verifies them again after a restart.

// daemon/internal/state/store.go func VerifyNodeState(raw []byte, signature string, v Verifier, serverID ServerID) (*SignedState, error) { kid, err := v.Verify(signature, raw) if err != nil { return nil, fmt.Errorf("state: %w", err) } ns, err := DecodeNodeState(raw) // unknown fields are rejected // … if ns.ServerID != serverID { return nil, &RejectedError{Version: ns.Version, Err: fmt.Errorf("state: NodeState is for server %s, this server is %s", ns.ServerID, serverID)} } return &SignedState{State: ns, Raw: raw, Signature: signature, KeyID: kid}, nil }

Environment variables are sealed with libsodium's crypto_box_seal to the receiving server's X25519 key. The sealed data includes the server and workload id, so a sealed blob can't be reused for another workload.

launchroomd internally polls every 30 seconds to the main dashboard, however when you quickly want to deploy this can feel slow. To make deploys feel immediate, the dashboard also sends a WebSocket message without any content that tells launchroomd to fetch now. In my dev setup, a click on "Deploy" reaches the server in about 1.4 s.

The NodeState has no expiry. The version counter already prevents replaying an older state, and with an expiry, apps would eventually stop while the dashboard is down. Without one, servers keep running the last state they verified: health checks continue, crons keep running because launchroomd schedules them itself, and Caddy restarts from its saved config.

Reconciliation then is a pure diff between the desired state and what Docker reports, followed by applying the plan:

// daemon/internal/reconcile/diff.go // Diff computes the plan that converges actual to desired at time now. It is // pure: no I/O, deterministic output order. func Diff(d Desired, a Actual, now time.Time, grace time.Duration) Plan {

launchroomd doesn't know about deployments or rollouts. The dashboard expresses a rolling update as new workload ids next to the old ones marked as draining, and launchroomd converges ids. This keeps all deployment logic in the dashboard, where it's easier to test and change.

launchroomd needs Docker to create containers, and access to the Docker socket is equivalent to root on the host. To keep a bug in launchroomd, or one of its dependencies, from becoming host root, launchroomd doesn't get the actual Docker socket either.

A second binary, dockerd-guard, owns the socket instead. It runs without network access, without capabilities and with a read-only filesystem. That daemon serves launchroomd a socket that accepts an allow-listed subset of the Docker Engine API. Everything else is refused, including build, commit, export, attach, kill, prune, events and plugins.

signed NodeState

allow-listed Engine API

/var/run/docker.sock

Dashboard

launchroomdpolicy check

dockerd-guardpolicy checkno network, no capabilities

dockerd

Filtering by path isn't enough: For example Docker’s POST /containers/create can contain "Privileged": true to start a priviliedged container. To prevent a server takeover with this, the guard decodes request bodies strictly and forwards a re-encoded copy of the struct it checked, not the original body:

// daemon/internal/guard/handle.go func decodeStrict(r *http.Request, v any) error { // … content type and 1 MiB size checks dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() if err := dec.Decode(v); err != nil { return deny("request body: %v", err) } if dec.More() { return deny("request body: trailing data") } return nil }

Go's encoding/json matches keys case-insensitively, and Docker's decoder could resolve duplicate keys differently. A body like {"Privileged": false, "privileged": true} could be read differently by the guard and by Docker. Re-encoding means we can be sure Docker really reads the final object the same way we did.

When theguard creates a container, it always adds the launchroom.managed=true label. For operations on existing containers, the guard first inspects the container, checks for the launchroom.managed=true label, and forwards the request using the full id from that inspection, so we can prevent taking over unrelated containers.

Both launchroomd and the guard also enforce a local policy, configured from a file launchroomd can't write. It covers the case where the dashboard itself is compromised and sends a validly signed state:

// daemon/internal/policy/policy.go if hc.Privileged { add("privileged", "privileged containers are not allowed") } if nm := string(hc.NetworkMode); nm == "host" || strings.HasPrefix(nm, "container:") { add("namespaces", "network mode %q is not allowed", nm) } if len(hc.Binds) > 0 || len(hc.VolumesFrom) > 0 || hc.VolumeDriver != "" || len(cfg.Volumes) > 0 { add("mounts", "bind mounts, volumes-from, volume drivers and anonymous volumes are not allowed") }

The policy also restricts routing. Route upstreams may only be mesh addresses or entries from a local allow-list, so a compromised dashboard can't route public traffic to Caddy's admin API, a database on localhost or a cloud metadata endpoint.

With one server, no private network is needed. When a second server is added, the dashboard enables Headscale, which is a self-hosted Tailscale server. Every server then has its own Tailscale client inside a Docker container, so it can communicate with all other instances. Servers behind NAT, like a machine at home, only need outgoing access to the main server on port 443, where Headscale's DERP relay also runs - so there’s no need for Cloudflare Tunnels, open ports etc.

However, being on the mesh doesn't grant anything by itself since anybody could just join some network. Headscale's ACL denies new clients by default, and each server additionally filters traffic arriving on tailscale0 with nftables. To authenticate servers, the dashboard gives out a temporary secret the new server can use, and can then exchange for its own signed certificate being added to the Dashboard.

On fun thing the Tailscale network allowed is routing custom service names between servers: For example, in a project the main api service might be on one server, while the connected postgres service in on a different one. With a local Docker network or Docker Swarm you could connect to the postgres service just using the hostname “postgres ”, but how to replicate this on a custom Tailscale network?

If api on server B connects to postgres on server A:

There is one timing issue with this: A new replica on another server can pass its health check before the database server has applied the firewall rule that allows it. In that case, its health endpoint answers, but every request that needs the database fails. So the dashboard only counts a replica as healthy once every server it connects to has reported a NodeState version that includes its mesh IP.

To allow a server that’s in the DNS routing to fail, launchroom also allows defining multiple “edge servers” that receive the traffic, handle TLS and then route requests to the actual servers hosting them.

Every edge server routes every service. Replicas on the same server are reached directly. Replicas on other servers are reached through their mesh address and published port. DNS can point at any edge, and for subdomains the dashboard recommends a CNAME to the service's generated hostname, so adding or replacing edges needs no DNS change.

Certificates need some coordination with several edges: With two or more shared edges, every edge's Caddy uses the dashboard's Valkey as shared certificate storage, over the mesh, with a Valkey ACL user limited to the commands Caddy's storage module needs. Caddy then coordinates ACME challenges between edges. Each launchroomd also mirrors the certificates it serves to local disk, so an edge can restart with valid certificates when the storage is unreachable.

Custom domains use Caddy's on-demand TLS. Caddy asks an endpoint whether it may get a certificate for a hostname, and that endpoint is answered by the local launchroomd from its cached routes, not by the dashboard. This keeps certificate issuance working wh

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →