Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions architecture/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ Dockerfile compiles Rust — both copy a staged binary out of

Binary staging is driven by `tasks/scripts/stage-prebuilt-binaries.sh`, which
runs `cargo build` natively on a matching host or `cargo zigbuild` when
cross-compiling. CI invokes the same staging step via the
`rust-native-build.yml` workflow (per-architecture, per-component) and uploads
the result as an artifact that the image build job downloads back into the
staging directory before running Buildx.
cross-compiling. Local Docker image tasks infer the target architecture from
`DOCKER_PLATFORM` when set, otherwise from the container engine host metadata
with the kernel architecture as the fallback. CI invokes the same staging step
via the `rust-native-build.yml` workflow (per-architecture, per-component) and
uploads the result as an artifact that the image build job downloads back into
the staging directory before running Buildx.

Runtime layout:

Expand Down
34 changes: 32 additions & 2 deletions tasks/scripts/container-engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,47 @@ ce_build() {
fi
}

# ---------------------------------------------------------------------------
# ce_normalize_arch — normalize common architecture names.
#
# Keeps container-engine helpers from silently drifting between Docker,
# Podman, and kernel naming conventions.
# ---------------------------------------------------------------------------
ce_normalize_arch() {
case "$1" in
x86_64|amd64) echo "amd64" ;;
aarch64|arm64) echo "arm64" ;;
*) echo "$1" ;;
esac
}

# ---------------------------------------------------------------------------
# ce_host_arch — kernel architecture normalized for Docker platform names.
# ---------------------------------------------------------------------------
ce_host_arch() {
ce_normalize_arch "$(uname -m)"
}

# ---------------------------------------------------------------------------
# ce_info_arch — host architecture reported by the container engine.
#
# Docker: docker info --format '{{.Architecture}}'
# Podman: podman info --format '{{.Host.Arch}}'
# Falls back to the kernel architecture when the daemon query is unavailable so
# local builds do not accidentally target amd64 on arm64 hosts.
# ---------------------------------------------------------------------------
ce_info_arch() {
local arch=""
if ce_is_docker; then
"${_CE_BIN}" info --format '{{.Architecture}}' 2>/dev/null || echo "amd64"
arch=$("${_CE_BIN}" info --format '{{.Architecture}}' 2>/dev/null || true)
else
arch=$("${_CE_BIN}" info --format '{{.Host.Arch}}' 2>/dev/null || true)
fi

if [[ -n "${arch}" ]]; then
ce_normalize_arch "${arch}"
else
"${_CE_BIN}" info --format '{{.Host.Arch}}' 2>/dev/null || echo "amd64"
ce_host_arch
fi
}

Expand Down
Loading