diff --git a/packages/system/dashboard/Makefile b/packages/system/dashboard/Makefile index c0267da1..10df5382 100644 --- a/packages/system/dashboard/Makefile +++ b/packages/system/dashboard/Makefile @@ -17,7 +17,8 @@ update-chart: patch --no-backup-if-mismatch charts/kubeapps/templates/frontend/configmap.yaml < patches/logos.patch update-dockerfiles: - tag=$$(git ls-remote --tags --sort="v:refname" https://github.com/vmware-tanzu/kubeapps | awk -F'[/^]' 'END{print $$3}') && \ + @echo Update dockerfiles manually + #tag=$$(git ls-remote --tags --sort="v:refname" https://github.com/vmware-tanzu/kubeapps | awk -F'[/^]' 'END{print $$3}') && \ wget https://github.com/vmware-tanzu/kubeapps/raw/$${tag}/cmd/kubeapps-apis/Dockerfile -O images/kubeapps-apis/Dockerfile && \ patch --no-backup-if-mismatch images/kubeapps-apis/Dockerfile < images/kubeapps-apis/dockerfile.diff && \ node_image=$$(wget -O- https://github.com/vmware-tanzu/kubeapps/raw/main/dashboard/Dockerfile | awk '/FROM bitnami\/node/ {print $$2}') && \ @@ -28,6 +29,8 @@ update-dockerfiles: image-dashboard: update-version docker buildx build images/dashboard \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/dashboard:$(call settag,$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/dashboard:latest \ --cache-to type=inline \ @@ -48,6 +51,8 @@ image-dashboard: update-version image-kubeapps-apis: update-version docker buildx build images/kubeapps-apis \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/kubeapps-apis:$(call settag,$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/kubeapps-apis:latest \ --cache-to type=inline \ diff --git a/packages/system/dashboard/images/kubeapps-apis/Dockerfile b/packages/system/dashboard/images/kubeapps-apis/Dockerfile index 05add84b..4825fb41 100644 --- a/packages/system/dashboard/images/kubeapps-apis/Dockerfile +++ b/packages/system/dashboard/images/kubeapps-apis/Dockerfile @@ -3,7 +3,7 @@ # syntax = docker/dockerfile:1 -FROM alpine as source +FROM alpine AS source ARG COMMIT_REF=dd02680d796c962b8dcc4e5ea70960a846c1acdc RUN apk add --no-cache patch WORKDIR /source @@ -12,8 +12,9 @@ RUN wget -O- https://github.com/cozystack/kubeapps/archive/${COMMIT_REF}.tar.gz FROM bitnami/golang:1.23.4 AS builder WORKDIR /go/src/github.com/vmware-tanzu/kubeapps COPY --from=source /source/go.mod /source/go.sum ./ -ARG VERSION="devel" +ARG TARGETOS ARG TARGETARCH +ARG VERSION="devel" # If true, run golangci-lint to detect issues ARG lint @@ -29,10 +30,12 @@ ARG GRPC_HEALTH_PROBE_VERSION="0.4.34" # Install lint tools RUN if [ ! -z ${lint:-} ]; then \ - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$GOLANGCILINT_VERSION; \ + GOOS=$TARGETOS GOARCH=$TARGETARCH go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$GOLANGCILINT_VERSION; \ fi -RUN curl -sSL "https://github.com/bufbuild/buf/releases/download/v$BUF_VERSION/buf-Linux-x86_64" -o "/tmp/buf" && chmod +x "/tmp/buf" +RUN if [ $TARGETARCH = 'amd64' ]; then BUF_ARCH='x86_64'; elif [ $TARGETARCH = 'arm64' ]; then BUF_ARCH='aarch64'; fi && \ + if [ $TARGETOS = 'linux' ]; then BUF_PLATFORM='Linux'; fi && \ + curl -sSL "https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-${BUF_PLATFORM}-${BUF_ARCH}" -o "/tmp/buf" && chmod +x "/tmp/buf" # TODO: Remove and instead use built-in gRPC container probes once we're supporting >= 1.24 only. https://kubernetes.io/blog/2022/05/13/grpc-probes-now-in-beta/ RUN curl -sSL "https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-${TARGETARCH}" -o "/bin/grpc_health_probe" && chmod +x "/bin/grpc_health_probe" @@ -41,7 +44,7 @@ RUN curl -sSL "https://github.com/grpc-ecosystem/grpc-health-probe/releases/down # https://github.com/golang/go/issues/27719#issuecomment-514747274 RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - GOPROXY="https://proxy.golang.org,direct" go mod download + GOOS=$TARGETOS GOARCH=$TARGETARCH GOPROXY="https://proxy.golang.org,direct" go mod download # We don't copy the pkg and cmd directories until here so the above layers can # be reused. @@ -60,7 +63,7 @@ RUN /tmp/buf lint ./cmd/kubeapps-apis # Build the main grpc server RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - GOPROXY="https://proxy.golang.org,direct" \ + GOOS=$TARGETOS GOARCH=$TARGETARCH GOPROXY="https://proxy.golang.org,direct" \ go build \ -ldflags "-X github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/cmd.version=$VERSION" \ ./cmd/kubeapps-apis @@ -68,7 +71,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \ ## Build 'fluxv2' plugin, version 'v1alpha1' RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - GOPROXY="https://proxy.golang.org,direct" \ + GOOS=$TARGETOS GOARCH=$TARGETARCH GOPROXY="https://proxy.golang.org,direct" \ go build \ -ldflags "-X github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/cmd.version=$VERSION" \ -o /fluxv2-packages-v1alpha1-plugin.so -buildmode=plugin \ @@ -77,7 +80,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \ ## Build 'helm' plugin, version 'v1alpha1' RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - GOPROXY="https://proxy.golang.org,direct" \ + GOOS=$TARGETOS GOARCH=$TARGETARCH GOPROXY="https://proxy.golang.org,direct" \ go build \ -ldflags "-X github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/cmd.version=$VERSION" \ -o /helm-packages-v1alpha1-plugin.so -buildmode=plugin \ @@ -86,7 +89,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \ ## Build 'resources' plugin, version 'v1alpha1' RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - GOPROXY="https://proxy.golang.org,direct" \ + GOOS=$TARGETOS GOARCH=$TARGETARCH GOPROXY="https://proxy.golang.org,direct" \ go build \ -ldflags "-X github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/cmd.version=$VERSION" \ -o /resources-v1alpha1-plugin.so -buildmode=plugin \