From e35dcdd4d8ebdcc5b10367ce2d7a5d4d9ac2e6a9 Mon Sep 17 00:00:00 2001 From: Jack He Date: Thu, 5 Aug 2021 21:18:45 -0700 Subject: [PATCH 1/2] add configurable ARCH --- Dockerfile | 3 ++- Makefile | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index a6508001..f3c7165d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM gcr.io/distroless/static:nonroot +ARG ARCH=arm64 WORKDIR / -COPY bin/manager ./ +COPY bin/${ARCH}/manager ./ USER nonroot:nonroot ENTRYPOINT ["/manager"] diff --git a/Makefile b/Makefile index f4c6c4e7..68b904ef 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,8 @@ else GOBIN=$(shell go env GOBIN) endif +ARCH?=arm64 + all-bootstrap: manager-bootstrap # Run tests @@ -24,7 +26,7 @@ test-bootstrap: generate-bootstrap fmt vet manifests-bootstrap # Build manager binary manager-bootstrap: generate-bootstrap fmt vet - CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o bin/manager bootstrap/main.go + CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags '-extldflags "-static"' -o bin/$(ARCH)/manager bootstrap/main.go # Run against the configured Kubernetes cluster in ~/.kube/config run-bootstrap: generate-bootstrap fmt vet manifests-bootstrap @@ -66,7 +68,7 @@ generate-bootstrap: controller-gen # Build the docker image docker-build-bootstrap: manager-bootstrap - docker build . -t ${BOOTSTRAP_IMG} + docker build . -t ${BOOTSTRAP_IMG} --build-arg $(ARCH) # Push the docker image docker-push-bootstrap: @@ -97,7 +99,7 @@ test-controlplane: generate-controlplane fmt vet manifests-controlplane # Build manager binary manager-controlplane: generate-controlplane fmt vet - CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o bin/manager controlplane/main.go + CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags '-extldflags "-static"' -o bin/$(ARCH)/manager controlplane/main.go # Run against the configured Kubernetes cluster in ~/.kube/config run-controlplane: generate-controlplane fmt vet manifests-controlplane @@ -130,7 +132,7 @@ generate-controlplane: controller-gen # Build the docker image docker-build-controlplane: manager-controlplane - docker build . -t ${CONTROLPLANE_IMG} + docker build . -t ${CONTROLPLANE_IMG} --build-arg $(ARCH) # Push the docker image docker-push-controlplane: From beb1a592122b228bcdfc4f94a04fbdc477a41784 Mon Sep 17 00:00:00 2001 From: Jack He Date: Thu, 5 Aug 2021 21:24:44 -0700 Subject: [PATCH 2/2] arm -> amd --- Dockerfile | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f3c7165d..792eb595 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM gcr.io/distroless/static:nonroot -ARG ARCH=arm64 +ARG ARCH=amd64 WORKDIR / COPY bin/${ARCH}/manager ./ USER nonroot:nonroot diff --git a/Makefile b/Makefile index 68b904ef..657fecd4 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ else GOBIN=$(shell go env GOBIN) endif -ARCH?=arm64 +ARCH?=amd64 all-bootstrap: manager-bootstrap