Documentation
¶
Overview ¶
Command portproxy is the sidecar half of giving self-hosted service mode a fixed, routable address.
Flockdeck's own server always binds 127.0.0.1 on a port chosen at random each start, with no bind-address flag and no way to pin the port (see internal/server.New) -- deliberately, since a desktop install has no business claiming a fixed port on someone's machine. That is fine for a desktop app, whose window dials its own process directly, but it means a Kubernetes Service or Ingress has nothing stable to route to: the port changes every restart, and nothing outside the pod can be told what it is ahead of time.
Containers in one pod share a network namespace, so a second, tiny container that listens on a fixed port and forwards every byte of every connection to whatever port flockdeck actually bound this run gives a Service exactly the fixed target it needs, without changing a line of flockdeck's own server code. That is all this program does. It discovers flockdeck's real address the same way a second `flockdeck` launch and docker/healthcheck.sh already do -- by reading the instance record flockdeck writes at start-up ($HOME/.config/flockdeck/instance.json, internal/store.SaveInstance) -- and re-reads it on every connection, so a restart that lands on a different port is picked up without this sidecar itself needing to be restarted.
It is deliberately not an HTTP-aware reverse proxy. flockdeck's own server already speaks HTTP, including the WebSocket upgrades /ws/control and /ws/pty use, and a byte-for-byte TCP relay forwards all of it -- headers, chunked bodies, upgrade handshakes, the auth token in the query string -- completely unchanged, without this program having to parse, buffer, or trust any of it. That also means it carries no authorization logic of its own: whoever connects through it still needs the token from the instance record, exactly as they would today over `kubectl port-forward` straight to flockdeck's own loopback port. The sidecar only fixes the address; it changes nothing about who is allowed to use it.
Built as a second binary in the same image as flockdeck itself (see the repository's Dockerfile) rather than shipped as its own container image, so it rides the same build, the same base-image hardening, the same CVE scan and the same cosign signature as flockdeck already gets -- one more image to pull, scan and trust independently would be a worse trade for a program this small.