fix(containers): remap identity bind sources to host paths in dev
The dev maestro container's data root is /data/.dcntrlized (XDG_DATA_HOME=/data), but bind-mount sources are resolved on the daemon's host namespace — a nonexistent /data/.dcntrlized/... source made Docker create empty directories, so the auth hub saw /dcntrlized/pki/tls.crt as a directory and TLS setup failed. DCNTRLIZED_HOST_DATA_ROOT (compose-injected, /home/franciscofadigas/.dcntrlized) is now substituted for the container-internal prefix when building identity bind sources. hostBindSource leaves paths unchanged on host installs.
This commit is contained in:
@@ -18,6 +18,7 @@ package containers
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -130,9 +131,9 @@ func injectServiceIdentity(ctx context.Context, project *composetypes.Project, s
|
||||
}
|
||||
|
||||
mounts := []string{
|
||||
fmt.Sprintf("%s:%s/ca.crt:ro", pki.CertPath(dataRoot), identityMountDir),
|
||||
fmt.Sprintf("%s:%s/tls.crt:ro", identity.CertPath, identityMountDir),
|
||||
fmt.Sprintf("%s:%s/tls.key:ro", identity.KeyPath, identityMountDir),
|
||||
fmt.Sprintf("%s:%s/ca.crt:ro", hostBindSource(dataRoot, pki.CertPath(dataRoot)), identityMountDir),
|
||||
fmt.Sprintf("%s:%s/tls.crt:ro", hostBindSource(dataRoot, identity.CertPath), identityMountDir),
|
||||
fmt.Sprintf("%s:%s/tls.key:ro", hostBindSource(dataRoot, identity.KeyPath), identityMountDir),
|
||||
}
|
||||
env := map[string]string{
|
||||
"SERVICE_NAME": serviceName,
|
||||
@@ -161,6 +162,22 @@ func injectServiceIdentity(ctx context.Context, project *composetypes.Project, s
|
||||
return nil
|
||||
}
|
||||
|
||||
// hostBindSource maps a dataRoot-relative path to a bind-mount source the
|
||||
// Docker daemon can resolve. Bind sources are resolved on the daemon's host
|
||||
// namespace, but inside the dev container the data root lives at a
|
||||
// container-internal path (/data/.dcntrlized via XDG_DATA_HOME=/data) that
|
||||
// does not exist on the host — the daemon would silently create it as an
|
||||
// empty directory. DCNTRLIZED_HOST_DATA_ROOT (compose-injected, e.g.
|
||||
// $HOME/.dcntrlized) carries the host path backing the data root; when set,
|
||||
// the container-internal prefix is swapped for it. On a host install the path
|
||||
// is already host-resolvable and returned unchanged.
|
||||
func hostBindSource(dataRoot, p string) string {
|
||||
if host := os.Getenv("DCNTRLIZED_HOST_DATA_ROOT"); host != "" && strings.HasPrefix(p, dataRoot) {
|
||||
return filepath.Join(host, strings.TrimPrefix(p, dataRoot))
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// pinAuthFingerprint returns the service's pinned auth fingerprint, fetching
|
||||
// and persisting it when the install record does not have one yet (M2 §5).
|
||||
// Best-effort: when the auth service is unreachable, it returns "" and the
|
||||
|
||||
Reference in New Issue
Block a user