Skip to main content

Module dev_relay

Module dev_relay 

Source
Expand description

A relay into the agents network, for a dev server srv cannot reach by the container’s IP.

The dev proxy (dev_proxy) forwards to the address a container agent’s dev server listens on. On Linux that is the container’s address on the agents network. On Docker Desktop (Windows and macOS) the daemon runs in a VM and container addresses are not routable from the host, so the same connection times out. There, one small container per host sits on the agents network with a single port published on 127.0.0.1; srv opens a connection to that port, names the container and port it wants, and the relay joins the two. One relay serves every agent and every project, it needs nothing published per dev server, and a WebSocket is just another connection.

The relay runs the agent image’s own node (nothing to pull), and takes a request line <token> <container> <port>, where the token is generated here and only the loopback caller that knows it is served. It only reaches containers named agentmux-*. srv adopts a running relay after a restart (the token is in its environment) and replaces one that is gone.

Structs§

RelayEndpoint
Where the relay can be reached and the token that opens it.

Constants§

RELAY_NAME
The relay container’s name. Not under agentmux-: that is the namespace of agent containers (container_name_for_slug), and an agent called dev-relay must not be the relay’s neighbour.

Functions§

connect
A connection to container:port through the relay at via.
ensure
The running relay, created if there is none. image is an image already on this machine (the one an agent container runs from).
needed
Whether this Docker keeps container addresses to itself: Docker Desktop, and any macOS or Windows host. AGENTMUX_DEV_PROXY_RELAY=1 (or 0) overrides it.