Skip to content
Closed
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
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ ARG GO_BUILD_FLAGS
ARG GO_LDFLAGS
ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM

RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/root/.cache/go-build,id=shim-build-$TARGETPLATFORM \
--mount=type=cache,target=/root/.cache/go-build,id=shim-build-${TARGETOS}/${TARGETARCH} \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build ${GO_DEBUG_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o /build/containerd-shim-nerdbox-v1 ${GO_LDFLAGS} -tags 'no_grpc' ./cmd/containerd-shim-nerdbox-v1

FROM base AS vminit-build
Expand Down
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ ROOTDIR=$(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
WHALE = "🇩"
ONI = "👹"

ARCH = $(shell uname -m)
OS = $(shell uname -s)
# Detect local platform
OS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH ?= $(shell uname -m)
export PLATFORM ?= $(OS)/$(ARCH)

LDFLAGS_x86_64_Linux = -lkrun
LDFLAGS_aarch64_Linux = -lkrun
LDFLAGS_arm64_Darwin = -L/opt/homebrew/lib -lkrun
Expand Down Expand Up @@ -52,10 +55,13 @@ GO_STATIC_LDFLAGS := -ldflags '-extldflags "-static" $(LDFLAGS) $(EXTRA_LDFLAGS)
MODULE_NAME=$(shell go list -m)
API_PACKAGES=$(shell ($(GO) list ${GO_TAGS} ./... | grep /api/ ))

.PHONY: clean all validate lint generate protos check-protos check-api-descriptors proto-fmt shell
.PHONY: clean all build validate lint generate protos check-protos check-api-descriptors proto-fmt shell

all: build

all:
$(BUILDX) bake
build:
@echo "$(WHALE) $@"
HOST_OS=$(OS) KERNEL_ARCH=$(ARCH) $(BUILDX) bake
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable naming inconsistency: KERNEL_ARCH is used here but TARGETARCH is the standard Docker build argument. Consider renaming to HOST_ARCH for consistency with HOST_OS, or document why a different convention is used.

Suggested change
HOST_OS=$(OS) KERNEL_ARCH=$(ARCH) $(BUILDX) bake
HOST_OS=$(OS) HOST_ARCH=$(ARCH) $(BUILDX) bake

Copilot uses AI. Check for mistakes.

_output/containerd-shim-nerdbox-v1: cmd/containerd-shim-nerdbox-v1 FORCE
@echo "$(WHALE) $@"
Expand Down
41 changes: 34 additions & 7 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# The host and guest OS may be different; set the host OS here.
variable "HOST_OS" {
default = "linux"
}

variable "KERNEL_VERSION" {
default = "6.12.46"
}
Expand Down Expand Up @@ -42,30 +47,56 @@ target "_common" {
}
}

target "_host_common" {
inherits = ["_common"]
args = {
TARGETOS = HOST_OS
}
}

target "_guest_common" {
inherits = ["_common"]
args = {
TARGETOS = "linux"
}
}

variable "DESTDIR" {
default = "_output"
}

group "default" {
targets = ["host-binaries", "guest-binaries", "kernel"]
}

group "host-binaries" {
targets = ["shim"]
}

group "guest-binaries" {
targets = ["initrd", "libkrun"]
}

target "menuconfig" {
inherits = ["_common"]
target = "kernel-build-base"
output = ["type=image,name=nerdbox-menuconfig"]
}

target "kernel" {
inherits = ["_common"]
inherits = ["_guest_common"]
target = "kernel"
output = ["${DESTDIR}"]
}

target "initrd" {
inherits = ["_common"]
inherits = ["_guest_common"]
target = "initrd"
output = ["${DESTDIR}"]
}

target "shim" {
inherits = ["_common"]
inherits = ["_host_common"]
target = "shim"
output = ["${DESTDIR}"]
}
Expand All @@ -76,10 +107,6 @@ target "libkrun" {
output = ["${DESTDIR}"]
}
Comment on lines 107 to 108
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The libkrun target is missing an inherits declaration. Since it's part of the guest-binaries group (line 77), it should inherit from _guest_common to ensure consistent platform targeting.

Copilot uses AI. Check for mistakes.

group "default" {
targets = ["kernel", "initrd", "shim"]
}

target "dev" {
inherits = ["_common"]
target = "dev"
Expand Down
Loading