Skip to content

Commit 4fbf18a

Browse files
authored
support multi arch for the demo (open-cluster-management-io#60)
Signed-off-by: myan <myan@redhat.com>
1 parent 51da052 commit 4fbf18a

3 files changed

Lines changed: 40 additions & 9 deletions

File tree

federated-learning-controller/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ docker-build: ## Build docker image with the manager.
112112
docker-push: ## Push docker image with the manager.
113113
$(CONTAINER_TOOL) push ${IMG}
114114

115+
# docker run --rm --privileged tonistiigi/binfmt --install all
116+
.PHONY: docker-platform-build
117+
docker-platform-build: ## Build docker image for multiple platforms (linux/amd64,linux/arm64).
118+
$(CONTAINER_TOOL) buildx build --platform linux/amd64,linux/arm64 -t ${IMG} .
119+
120+
.PHONY: docker-platform-push
121+
docker-platform-push: ## Build and push docker image for multiple platforms (linux/amd64,linux/arm64).
122+
$(CONTAINER_TOOL) buildx build --platform linux/amd64,linux/arm64 --push -t ${IMG} .
123+
115124
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
116125
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
117126
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
1-
21
# Variables
32
REGISTRY ?= quay.io/open-cluster-management
43
IMAGE_TAG ?= latest
54
DIST_DIR = dist
65
APP = app-torch
6+
PLATFORMS ?= linux/amd64,linux/arm64
7+
IMAGE_FULL_NAME = ${REGISTRY}/flower-${APP}:${IMAGE_TAG}
78

9+
# Single-arch build (local)
810
build-app-image:
9-
cd ${APP} && docker build -t ${REGISTRY}/flower-${APP}:${IMAGE_TAG} . -f Dockerfile && cd ..
11+
cd ${APP} && docker build -t ${IMAGE_FULL_NAME} . -f Dockerfile && cd ..
1012

13+
# Single-arch push
1114
push-app-image:
12-
docker push ${REGISTRY}/flower-${APP}:${IMAGE_TAG}
15+
docker push ${IMAGE_FULL_NAME}
16+
17+
# Multi-arch build without push (export to local registry/engine not supported directly)
18+
build-platform-image:
19+
cd ${APP} && \
20+
docker buildx build \
21+
--platform ${PLATFORMS} \
22+
--tag ${IMAGE_FULL_NAME} \
23+
--output=type=docker \
24+
. -f Dockerfile && cd ..
25+
26+
# Multi-arch push (requires --push during buildx)
27+
push-platform-image:
28+
cd ${APP} && \
29+
docker buildx build \
30+
--platform ${PLATFORMS} \
31+
--tag ${IMAGE_FULL_NAME} \
32+
--push \
33+
. -f Dockerfile && cd ..
1334

35+
# Clean
1436
clean:
15-
rm -rf $(DIST_DIR) __pycache__ *.spec
37+
rm -rf $(DIST_DIR) __pycache__ *.spec

federated-learning-controller/go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ module github/open-cluster-management/federated-learning
33
go 1.23.0
44

55
require (
6+
github.com/go-logr/logr v1.4.2
7+
github.com/go-logr/zapr v1.3.0
68
github.com/onsi/ginkgo/v2 v2.21.0
79
github.com/onsi/gomega v1.35.1
10+
github.com/openshift/api v0.0.0-20240527133614-ba11c1587003
811
github.com/openshift/library-go v0.0.0-20240723172506-8bb8fe6cc56d
912
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.79.2
13+
go.uber.org/zap v1.27.0
1014
k8s.io/api v0.32.0
1115
k8s.io/apimachinery v0.32.0
1216
k8s.io/client-go v0.32.0
13-
k8s.io/klog/v2 v2.130.1
1417
open-cluster-management.io/api v0.15.0
1518
sigs.k8s.io/controller-runtime v0.19.3
1619
)
@@ -29,9 +32,7 @@ require (
2932
github.com/felixge/httpsnoop v1.0.4 // indirect
3033
github.com/fsnotify/fsnotify v1.7.0 // indirect
3134
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
32-
github.com/go-logr/logr v1.4.2 // indirect
3335
github.com/go-logr/stdr v1.2.2 // indirect
34-
github.com/go-logr/zapr v1.3.0 // indirect
3536
github.com/go-openapi/jsonpointer v0.21.0 // indirect
3637
github.com/go-openapi/jsonreference v0.20.2 // indirect
3738
github.com/go-openapi/swag v0.23.0 // indirect
@@ -52,7 +53,6 @@ require (
5253
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5354
github.com/modern-go/reflect2 v1.0.2 // indirect
5455
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
55-
github.com/openshift/api v0.0.0-20240527133614-ba11c1587003 // indirect
5656
github.com/pkg/errors v0.9.1 // indirect
5757
github.com/prometheus/client_golang v1.19.1 // indirect
5858
github.com/prometheus/client_model v0.6.1 // indirect
@@ -71,7 +71,6 @@ require (
7171
go.opentelemetry.io/otel/trace v1.28.0 // indirect
7272
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
7373
go.uber.org/multierr v1.11.0 // indirect
74-
go.uber.org/zap v1.27.0 // indirect
7574
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
7675
golang.org/x/net v0.32.0 // indirect
7776
golang.org/x/oauth2 v0.23.0 // indirect
@@ -92,6 +91,7 @@ require (
9291
k8s.io/apiextensions-apiserver v0.32.0 // indirect
9392
k8s.io/apiserver v0.32.0 // indirect
9493
k8s.io/component-base v0.32.0 // indirect
94+
k8s.io/klog/v2 v2.130.1 // indirect
9595
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
9696
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect
9797
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 // indirect

0 commit comments

Comments
 (0)