fix dashboard build (#499)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced build process for Kubeapps with improved modularity and patch
integration.
	- Introduced version specification for Kubeapps builds.

- **Bug Fixes**
	- Streamlined plugin build commands for better performance and clarity.

- **Refactor**
- Restructured Dockerfile to utilize different base images and optimize
the build stages.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
klinch0
2024-12-03 13:54:20 +03:00
committed by GitHub
parent f73a5a0fcb
commit ba421182cd

View File

@@ -3,9 +3,23 @@
# syntax = docker/dockerfile:1
FROM bitnami/golang:1.23.2 AS builder
FROM alpine as source
ARG VERSION=v2.11.0
RUN apk add --no-cache patch
WORKDIR /source
RUN wget -O- https://github.com/vmware-tanzu/kubeapps/archive/refs/tags/${VERSION}.tar.gz | tar xzf - --strip-components=1
COPY fluxcd.diff /patches/fluxcd.diff
COPY labels.diff /patches/labels.diff
COPY reconcile-strategy.diff /patches/reconcile-strategy.diff
COPY dashboard-resource.diff /patches/dashboard-resource.diff
RUN patch -p1 < /patches/fluxcd.diff
RUN patch -p1 < /patches/labels.diff
RUN patch -p1 < /patches/reconcile-strategy.diff
RUN patch -p1 < /patches/dashboard-resource.diff
FROM bitnami/golang:1.22.5 AS builder
WORKDIR /go/src/github.com/vmware-tanzu/kubeapps
COPY go.mod go.sum ./
COPY --from=source /source/go.mod /source/go.sum ./
ARG VERSION="devel"
ARG TARGETARCH
@@ -40,8 +54,8 @@ RUN --mount=type=cache,target=/go/pkg/mod \
# We don't copy the pkg and cmd directories until here so the above layers can
# be reused.
COPY pkg pkg
COPY cmd cmd
COPY --from=source /source/pkg pkg
COPY --from=source /source/cmd cmd
RUN if [ ! -z ${lint:-} ]; then \
# Run golangci-lint to detect issues
@@ -60,15 +74,6 @@ RUN --mount=type=cache,target=/go/pkg/mod \
-ldflags "-X github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/cmd.version=$VERSION" \
./cmd/kubeapps-apis
# Build 'kapp-controller' 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" \
go build \
-ldflags "-X github.com/vmware-tanzu/kubeapps/cmd/kubeapps-apis/cmd.version=$VERSION" \
-o /kapp-controller-packages-v1alpha1-plugin.so -buildmode=plugin \
./cmd/kubeapps-apis/plugins/kapp_controller/packages/v1alpha1/*.go
## Build 'fluxv2' plugin, version 'v1alpha1'
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
@@ -101,7 +106,6 @@ RUN --mount=type=cache,target=/go/pkg/mod \
FROM bitnami/minideb:bookworm
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/src/github.com/vmware-tanzu/kubeapps/kubeapps-apis /kubeapps-apis
COPY --from=builder /kapp-controller-packages-v1alpha1-plugin.so /plugins/kapp-controller-packages/
COPY --from=builder /fluxv2-packages-v1alpha1-plugin.so /plugins/fluxv2-packages/
COPY --from=builder /helm-packages-v1alpha1-plugin.so /plugins/helm-packages/
COPY --from=builder /resources-v1alpha1-plugin.so /plugins/resources/