Add multi-arch Docker build and docker-compose stack

Introduce a multi-stage Alpine Dockerfile that cross-compiles via
buildx ($BUILDPLATFORM -> $TARGETARCH) so a single invocation produces
both linux/amd64 and linux/arm64 images without a qemu-emulated
builder. `make docker` loads the native-arch image locally for smoke
tests; `make docker-push` publishes a multi-arch manifest. Ship a
docker-compose.yaml with opt-in profiles for maglevd/frontend and a
.env.example template so operators can mirror /etc/default/vpp-maglev
muscle memory into containers.
This commit is contained in:
2026-04-15 18:07:07 +02:00
parent bc6ccaa844
commit 6a48c12449
6 changed files with 291 additions and 24 deletions

View File

@@ -54,7 +54,7 @@ GO_VERSION ?= 1.25.0
# make install-deps GOLANGCI_LINT_VERSION=2.0.0
GOLANGCI_LINT_VERSION ?= 1.64.0
.PHONY: all build build-amd64 build-arm64 test proto vpp-binapi lint fixstyle fixstyle-web pkg-deb robot-test clean maglevd-frontend-web install-deps install-deps-apt install-deps-go install-deps-go-tools
.PHONY: all build build-amd64 build-arm64 test proto vpp-binapi lint fixstyle fixstyle-web pkg-deb docker docker-push robot-test clean maglevd-frontend-web install-deps install-deps-apt install-deps-go install-deps-go-tools
all: build
@@ -93,6 +93,27 @@ pkg-deb: build-amd64 build-arm64
debian/build-deb.sh vpp-maglev amd64 $(VERSION)
debian/build-deb.sh vpp-maglev arm64 $(VERSION)
# docker — build both container images for the current host arch and
# load them into the local docker daemon. Uses buildx so the Dockerfile
# can cross-compile via $TARGETARCH; --load only supports a single
# platform, so this target is for local smoke tests. Use docker-push
# for a true multi-arch manifest. Each image is tagged both :v$(VERSION)
# and :latest in one build, so bumping VERSION is the only change
# needed to cut a new release — no hand-edited tag lists to forget.
docker:
docker buildx build --load --target maglevd -t git.ipng.ch/ipng/vpp-maglevd:v$(VERSION) -t git.ipng.ch/ipng/vpp-maglevd:latest .
docker buildx build --load --target frontend -t git.ipng.ch/ipng/vpp-maglevd-frontend:v$(VERSION) -t git.ipng.ch/ipng/vpp-maglevd-frontend:latest .
# docker-push — build a multi-arch (linux/amd64,linux/arm64) manifest
# for both images and push it straight to the registry, tagged both
# :v$(VERSION) and :latest. Buildx won't --load a multi-platform
# result into the local daemon, so push is the only way to
# materialise the combined manifest. Assumes the caller is already
# logged in to git.ipng.ch.
docker-push:
docker buildx build --platform linux/amd64,linux/arm64 --push --target maglevd -t git.ipng.ch/ipng/vpp-maglevd:v$(VERSION) -t git.ipng.ch/ipng/vpp-maglevd:latest .
docker buildx build --platform linux/amd64,linux/arm64 --push --target frontend -t git.ipng.ch/ipng/vpp-maglevd-frontend:v$(VERSION) -t git.ipng.ch/ipng/vpp-maglevd-frontend:latest .
test: $(GEN_FILES)
go test ./...