feat(services): volume mounts + admin volume inventory (C1)

services.volumes JSONB [{type: volume|bind, source, target, read_only}]
mapped into every replica's container config at deploy and reconcile
time, hashed into the runtime spec so mount changes trigger
reconciliation. Mounted via existing docker.HostConfig.Mounts.

- RuntimeSpec.Volumes + specHash + mount.Mount mapping in createReplica
- Create/update service accepts volumes; PUT replaces the whole list
- Replica-count reconcile now goes through the deploy queue — the last
  raw `go` reconcile left that could race a build
- GET /admin/volumes inventories node volumes with in_use flags;
  DELETE /admin/volumes/:name removes unused ones (409 on in-use)
- CLI: services update --volume/--bind/--clear-volumes, volumes
  list|delete; MCP: services_update + volumes_list/delete
- Settings UI: Volumes section with mount editor
- Migration normalizes the nullable baseline column to NOT NULL [].

Verified live: deploy applies mounts to the container, docker
auto-creates named volumes, in-use deletion is refused.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Tomas DvorakandDevin committed 2026-10-08 16:38:46 +02:00
1 parent 747b714a02
commit 2f8f595d6e
21 files changed
+863 -93

No files matched your search

+17 -1
View File
@@ -17,6 +17,7 @@ import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network"
"github.com/docker/go-connections/nat"
)
@@ -47,6 +48,7 @@ type RuntimeSpec struct {
RestartPolicy string
MemoryBytes int64
NanoCPUs int64
Volumes []VolumeMount // applied to every replica
}
// RuntimeContainer describes one live replica.
@@ -245,6 +247,19 @@ func (de *DeploymentEngine) createReplica(ctx context.Context, spec RuntimeSpec,
Networks: endpoints,
}
for _, v := range spec.Volumes {
mountType := mount.TypeVolume
if v.Type == "bind" {
mountType = mount.TypeBind
}
cfg.Mounts = append(cfg.Mounts, mount.Mount{
Type: mountType,
Source: v.Source,
Target: v.Destination,
ReadOnly: v.ReadOnly,
})
}
var wantPort nat.Port
if spec.Port > 0 {
wantPort = nat.Port(fmt.Sprintf("%d/tcp", spec.Port))
@@ -474,8 +489,9 @@ func specHash(spec RuntimeSpec) string {
Env map[string]string
Port int32
MemoryBytes, NanoCPUs int64
Volumes []VolumeMount
}{spec.Image, spec.Name, spec.Domain, spec.HealthPath, spec.RestartPolicy,
spec.Command, spec.Env, spec.Port, spec.MemoryBytes, spec.NanoCPUs})
spec.Command, spec.Env, spec.Port, spec.MemoryBytes, spec.NanoCPUs, spec.Volumes})
sum := sha256.Sum256(payload)
return hex.EncodeToString(sum[:8])
}