Skip to content

socketd: expose backend-backed Docker snapshot inventory for Portainer#138

Merged
ravindu644 merged 6 commits into
ravindu644:devfrom
yoshi3jp:web
May 18, 2026
Merged

socketd: expose backend-backed Docker snapshot inventory for Portainer#138
ravindu644 merged 6 commits into
ravindu644:devfrom
yoshi3jp:web

Conversation

@yoshi3jp
Copy link
Copy Markdown
Contributor

Summary

This extends the experimental droidspaces-socketd Web API path so that the
Portainer-facing Docker-compatible snapshot endpoints are no longer dummy-only.

The previous socketd work established:

  • TCP Docker-compatible discovery endpoints for Portainer probing
  • placeholder snapshot responses for:
    • /containers/json
    • /images/json
    • /volumes
    • /networks
    • /events

This PR keeps the public HTTP compatibility layer in src/socketd/, but adds
the privileged backend protocol and typed client plumbing needed to expose
real Droidspaces runtime state through those endpoints.

What changed

Private backend protocol

Extended the private socketd backend protocol with opcodes and capabilities for:

  • container inventory
  • image-style inventory projection
  • backend info counters
  • lifecycle event polling

The protocol gains typed request/response records for:

  • container listing
  • pseudo-image listing
  • event polling
  • event records
  • INFO counters

The bridge dispatch path was also adjusted so payload-bearing opcodes can read
their own request bodies instead of all payloads being discarded before opcode
handling.

Backend bridge inventory

Implemented privileged backend handlers for:

  • LIST_CONTAINERS

    • enumerates running containers from the PID sidecars
    • optionally includes stopped installed containers from mirrored workspace
      configs
    • exports container name, UUID, rootfs reference, hostname, networking mode,
      NAT IP, custom init, PID, forwarded ports, and start timestamp
  • INFO

    • reports total / running / stopped container counts
  • LIST_IMAGES

    • exposes one socketd-side pseudo-image record per installed Droidspaces
      container config
  • POLL_EVENTS

    • returns retained lifecycle records from a core-side binary event journal

Core lifecycle events

Added a small best-effort core event journal under the Droidspaces logs
workspace and record lifecycle events for:

  • container start
  • explicit stop / die
  • internal restart loop

These records are later consumed by the socketd backend event poller.

Typed C++ backend client

Extended BackendClient with typed methods for:

  • list_containers()
  • info()
  • list_images()
  • poll_events()

This keeps binary bridge parsing out of the HTTP/JSON code paths.

Public socketd JSON projections

Replaced the snapshot dummy seams with backend-backed JSON generation:

  • /containers/json

    • now renders Docker-compatible container summaries from real Droidspaces
      inventory
  • /volumes

    • intentionally remains structurally valid but empty, since Droidspaces
      currently has bind mounts rather than Docker-managed named volumes
  • /networks

    • now exposes fixed Docker-shaped compatibility descriptors for:
      • droidspaces-bridge
      • host
      • none
  • /events

    • merges existing socketd-local daemon events with core lifecycle events
      fetched from the privileged backend
  • /info

    • now uses backend container counts instead of fixed placeholder zeros

Design notes

This continues the intended architecture for the WebUI daemon:

  • Droidspaces core remains C
  • socketd remains the Docker/Portainer compatibility boundary
  • JSON rendering remains entirely in the C++ socketd layer
  • the privileged bridge uses small typed binary payloads instead of JSON

The snapshot projections are deliberately compatibility-oriented. They are not
intended to turn Droidspaces into Docker internally; they provide enough
Docker-shaped surface for Portainer to represent Droidspaces state while keeping
the underlying runtime model intact.

Current scope

This PR focuses on the snapshot/discovery surfaces Portainer requests during
environment loading and dashboard rendering.

It does not yet implement container lifecycle control routes such as:

  • POST /containers/{id}/start
  • POST /containers/{id}/stop

Those remain natural follow-up work once the inventory-facing WebUI path is
accepted and tested further.

@ravindu644 ravindu644 merged commit 8716a9c into ravindu644:dev May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants