diff --git a/internal/biome/biome.go b/internal/biome/biome.go index 2326006..3c95ac5 100644 --- a/internal/biome/biome.go +++ b/internal/biome/biome.go @@ -89,6 +89,7 @@ const ( const ( Intel64 = "amd64" Intel32 = "386" + ARM64 = "arm64" ) // Dirs holds paths to special directories in a Context. diff --git a/internal/biome/docker.go b/internal/biome/docker.go index 675763e..0b6f0dc 100644 --- a/internal/biome/docker.go +++ b/internal/biome/docker.go @@ -254,10 +254,25 @@ func DockerDescriptor(ctx context.Context, client *docker.Client) (*Descriptor, if info.OSType == "" || info.Architecture == "" { return nil, fmt.Errorf("docker info: missing OSType and/or Architecture") } - return &Descriptor{ - OS: info.OSType, - Arch: info.Architecture, - }, nil + desc := &Descriptor{ + OS: info.OSType, + // While the Docker documentation claims that it uses runtime.GOARCH, + // it actually uses the syscall equivalent of `uname -m`. + // Source: https://github.com/moby/moby/blob/v20.10.7/pkg/platform/architecture_unix.go + Arch: map[string]string{ + "x86": Intel32, + "x86_64": Intel64, + // macOS uses arm64 and Linux uses aarch64. https://stackoverflow.com/a/47274698 + // Not sure if we'll encounter the Docker daemon running on macOS directly, + // but including both variants for sake of completeness. + "arm64": ARM64, + "aarch64": ARM64, + }[info.Architecture], + } + if desc.Arch == "" { + return nil, fmt.Errorf("docker info: unknown architecture %q", info.Architecture) + } + return desc, nil } // Dirs returns special directories.