Skip to content

Commit

Permalink
Merge pull request redpanda-data#13174 from vbotbuildovich/backport-p…
Browse files Browse the repository at this point in the history
…r-13166-v23.2.x-366

[v23.2.x] k8s: makefile change to make building on osx faster
  • Loading branch information
RafalKorepta authored Aug 31, 2023
2 parents 784fbb0 + 1e7bc04 commit 9fe612d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/go/k8s/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/golang:1.20.4 as builder

ARG TARGETARCH
ARG TARGETOS

# Copy the rpk as a close depedency
WORKDIR /workspace
Expand All @@ -19,8 +20,8 @@ RUN go mod download
COPY k8s/ .

# build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -a -o manager main.go && \
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -a -o configurator cmd/configurator/main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on go build -a -o manager main.go && \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on go build -a -o configurator cmd/configurator/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
20 changes: 11 additions & 9 deletions src/go/k8s/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Image URL to use all building/pushing image targets
OPERATOR_IMG_LATEST ?= "localhost/redpanda-operator:dev"
CONFIGURATOR_IMG_LATEST ?= "localhost/configurator:dev"
Expand All @@ -11,23 +10,25 @@ REDPANDA_IMG ?= "localhost/redpanda:dev"
# default redpanda namespace
NAMESPACE ?= "redpanda"

ifeq (aarch64,$(uname -m))
TARGETARCH = arm64
ifeq (aarch64,$(shell uname -m))
TARGETARCH = arm64
else
TARGETARCH = amd64
TARGETARCH ?= $(shell uname -m)
endif

TARGETOS ?= linux

SHELL := /bin/bash

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
GOBIN=$(shell go env GOBIN)
endif

ifneq ($(TEST_NAME), )
TEST_ONLY_FLAG = --test $(TEST_NAME)
TEST_ONLY_FLAG = --test $(TEST_NAME)
endif

all: manager
Expand Down Expand Up @@ -96,12 +97,13 @@ prepare-dockerfile:
# Build the docker image
docker-build: prepare-dockerfile
echo "~~~ Building operator image :docker:"
docker buildx build --build-arg BUILDPLATFORM='linux/${TARGETARCH}' --build-arg TARGETARCH=${TARGETARCH} --target=manager --load -f Dockerfile.out -t ${OPERATOR_IMG_LATEST} ../
echo building '${TARGETOS}/${TARGETARCH}'
docker buildx build --build-arg BUILDPLATFORM='${TARGETOS}/${TARGETARCH}' --build-arg TARGETARCH=${TARGETARCH} --build-arg TARGETOS=${TARGETOS} --target=manager --load -f Dockerfile.out -t ${OPERATOR_IMG_LATEST} ../

# Build the docker image
docker-build-configurator: prepare-dockerfile
echo "~~~ Building configurator image :docker:"
docker buildx build --build-arg BUILDPLATFORM='linux/${TARGETARCH}' --build-arg TARGETARCH=${TARGETARCH} --target=configurator --load -f Dockerfile.out -t ${CONFIGURATOR_IMG_LATEST} ../
docker buildx build --build-arg BUILDPLATFORM='${TARGETOS}/${TARGETARCH}' --build-arg TARGETARCH=${TARGETARCH} --build-arg TARGETOS=${TARGETOS} --target=configurator --load -f Dockerfile.out -t ${CONFIGURATOR_IMG_LATEST} ../

# Preload controller image to kind cluster
push-to-kind: kind-create certmanager-install
Expand Down

0 comments on commit 9fe612d

Please sign in to comment.