From 01e07f4d8893a4740d4f76a9eb0b144c49dd9daa Mon Sep 17 00:00:00 2001 From: Alex Jones Date: Mon, 24 Apr 2023 16:34:57 +0200 Subject: [PATCH] chore: updated readme Signed-off-by: Alex Jones --- Dockerfile | 6 ++++-- Makefile | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f9cca18..6aef2937 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ # Build the manager binary -FROM golang:1.19 as builder +FROM --platform=$BUILDPLATFORM golang:1.20.3-alpine3.16 AS builder + ARG TARGETOS ARG TARGETARCH @@ -14,6 +15,7 @@ RUN go mod download # Copy the go source COPY main.go main.go COPY api/ api/ +COPY pkg/ pkg/ COPY controllers/ controllers/ # Build @@ -21,7 +23,7 @@ COPY controllers/ controllers/ # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o manager main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Makefile b/Makefile index 17ec139c..f564c0b4 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ run: manifests generate fmt vet ## Run a controller from your host. .PHONY: docker-build docker-build: test ## Build docker image with the manager. @echo "===========> Building docker image" - docker buildx build --build-arg=VERSION="$$(git rev-parse --short HEAD)" --build-arg=COMMIT="$$(git rev-parse --short HEAD)" --build-arg DATE="$$(date +%FT%TZ)" --platform="linux/amd64,linux/arm64" -t ${IMG} -f container/Dockerfile . --push + docker buildx build --build-arg=VERSION="$$(git describe --tags --abbrev=0)" --build-arg=COMMIT="$$(git rev-parse --short HEAD)" --build-arg DATE="$$(date +%FT%TZ)" --platform="linux/amd64,linux/arm64" -t ${IMG} . --push # PLATFORMS defines the target platforms for the manager image be build to provide support to multiple # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: @@ -82,7 +82,7 @@ docker-build: test ## Build docker image with the manager. # - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ # - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) # To properly provided solutions that supports more than one platform you should use this option. -PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le +PLATFORMS ?= linux/arm64,linux/amd64 .PHONY: docker-buildx docker-buildx: test ## Build and push docker image for the manager for cross-platform support # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile