diff --git a/packages/apps/clickhouse/Makefile b/packages/apps/clickhouse/Makefile index 10460cb0..ae59ae22 100644 --- a/packages/apps/clickhouse/Makefile +++ b/packages/apps/clickhouse/Makefile @@ -7,8 +7,10 @@ generate: readme-generator -v values.yaml -s values.schema.json -r README.md image: - docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/clickhouse-backup \ + docker buildx build images/clickhouse-backup \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/clickhouse-backup:$(call settag,$(CLICKHOUSE_BACKUP_TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/clickhouse-backup:latest \ --cache-to type=inline \ diff --git a/packages/apps/http-cache/Makefile b/packages/apps/http-cache/Makefile index 833a817d..c8270993 100644 --- a/packages/apps/http-cache/Makefile +++ b/packages/apps/http-cache/Makefile @@ -6,8 +6,10 @@ include ../../../scripts/package.mk image: image-nginx image-nginx: - docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/nginx-cache \ + docker buildx build images/nginx-cache \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/nginx-cache:$(call settag,$(NGINX_CACHE_TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/nginx-cache:latest \ --cache-to type=inline \ diff --git a/packages/apps/http-cache/images/nginx-cache/Dockerfile b/packages/apps/http-cache/images/nginx-cache/Dockerfile index f121a3ab..2425acf7 100644 --- a/packages/apps/http-cache/images/nginx-cache/Dockerfile +++ b/packages/apps/http-cache/images/nginx-cache/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 as stage +FROM ubuntu:22.04 AS stage ARG NGINX_VERSION=1.25.3 ARG IP2LOCATION_C_VERSION=8.6.1 @@ -9,11 +9,15 @@ ARG FIFTYONEDEGREES_NGINX_VERSION=3.2.21.1 ARG NGINX_CACHE_PURGE_VERSION=2.5.3 ARG NGINX_VTS_VERSION=0.2.2 +ARG TARGETOS +ARG TARGETARCH + # Install required packages for development -RUN apt-get update -q \ - && apt-get install -yq \ +RUN apt update -q \ + && apt install -yq --no-install-recommends \ + ca-certificates \ unzip \ - autoconf \ + automake \ build-essential \ libtool \ libpcre3 \ @@ -68,7 +72,7 @@ RUN checkinstall \ --default \ --pkgname=ip2location-c \ --pkgversion=${IP2LOCATION_C_VERSION} \ - --pkgarch=amd64 \ + --pkgarch=${TARGETARCH} \ --pkggroup=lib \ --pkgsource="https://github.com/chrislim2888/IP2Location-C-Library" \ --maintainer="Eduard Generalov " \ @@ -97,7 +101,7 @@ RUN checkinstall \ --default \ --pkgname=ip2proxy-c \ --pkgversion=${IP2PROXY_C_VERSION} \ - --pkgarch=amd64 \ + --pkgarch=${TARGETARCH} \ --pkggroup=lib \ --pkgsource="https://github.com/ip2location/ip2proxy-c" \ --maintainer="Eduard Generalov " \ @@ -144,7 +148,7 @@ RUN checkinstall \ --default \ --pkgname=nginx \ --pkgversion=$VERS \ - --pkgarch=amd64 \ + --pkgarch=${TARGETARCH} \ --pkggroup=web \ --provides=nginx \ --requires=ip2location-c,ip2proxy-c,libssl3,libc-bin,libc6,libzstd1,libpcre++0v5,libpcre16-3,libpcre2-8-0,libpcre3,libpcre32-3,libpcrecpp0v5,libmaxminddb0 \ @@ -165,10 +169,9 @@ COPY nginx-reloader.sh /usr/bin/nginx-reloader.sh RUN set -x \ && groupadd --system --gid 101 nginx \ && useradd --system --gid nginx --no-create-home --home /nonexistent --comment "nginx user" --shell /bin/false --uid 101 nginx \ - && apt update \ - && apt-get install --no-install-recommends --no-install-suggests -y gnupg1 ca-certificates inotify-tools \ - && apt -y install /packages/*.deb \ - && apt-get clean \ + && apt update -q \ + && apt install -yq --no-install-recommends --no-install-suggests gnupg1 ca-certificates inotify-tools \ + && apt install -y /packages/*.deb \ && rm -rf /var/lib/apt/lists/* \ && mkdir -p /var/lib/nginx /var/log/nginx \ && ln -sf /dev/stdout /var/log/nginx/access.log \ diff --git a/packages/apps/kubernetes/Makefile b/packages/apps/kubernetes/Makefile index 45b97f69..10898e65 100644 --- a/packages/apps/kubernetes/Makefile +++ b/packages/apps/kubernetes/Makefile @@ -14,8 +14,10 @@ generate: image: image-ubuntu-container-disk image-kubevirt-cloud-provider image-kubevirt-csi-driver image-cluster-autoscaler image-ubuntu-container-disk: - docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/ubuntu-container-disk \ + docker buildx build images/ubuntu-container-disk \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --build-arg KUBERNETES_VERSION=${KUBERNETES_VERSION} \ --tag $(REGISTRY)/ubuntu-container-disk:$(call settag,$(KUBERNETES_VERSION)) \ --tag $(REGISTRY)/ubuntu-container-disk:$(call settag,$(KUBERNETES_VERSION)-$(TAG)) \ @@ -30,8 +32,10 @@ image-ubuntu-container-disk: rm -f images/ubuntu-container-disk.json image-kubevirt-cloud-provider: - docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/kubevirt-cloud-provider \ + docker buildx build images/kubevirt-cloud-provider \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/kubevirt-cloud-provider:$(call settag,$(KUBERNETES_PKG_TAG)) \ --tag $(REGISTRY)/kubevirt-cloud-provider:$(call settag,$(KUBERNETES_PKG_TAG)-$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/kubevirt-cloud-provider:latest \ @@ -45,8 +49,10 @@ image-kubevirt-cloud-provider: rm -f images/kubevirt-cloud-provider.json image-kubevirt-csi-driver: - docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/kubevirt-csi-driver \ + docker buildx build images/kubevirt-csi-driver \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/kubevirt-csi-driver:$(call settag,$(KUBERNETES_PKG_TAG)) \ --tag $(REGISTRY)/kubevirt-csi-driver:$(call settag,$(KUBERNETES_PKG_TAG)-$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/kubevirt-csi-driver:latest \ @@ -61,8 +67,10 @@ image-kubevirt-csi-driver: image-cluster-autoscaler: - docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/cluster-autoscaler \ + docker buildx build images/cluster-autoscaler \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/cluster-autoscaler:$(call settag,$(KUBERNETES_PKG_TAG)) \ --tag $(REGISTRY)/cluster-autoscaler:$(call settag,$(KUBERNETES_PKG_TAG)-$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/cluster-autoscaler:latest \ diff --git a/packages/apps/kubernetes/images/cluster-autoscaler/Dockerfile b/packages/apps/kubernetes/images/cluster-autoscaler/Dockerfile index 17a5e501..7f9ff896 100644 --- a/packages/apps/kubernetes/images/cluster-autoscaler/Dockerfile +++ b/packages/apps/kubernetes/images/cluster-autoscaler/Dockerfile @@ -1,7 +1,14 @@ # Source: https://raw.githubusercontent.com/kubernetes/autoscaler/refs/heads/master/cluster-autoscaler/Dockerfile.amd64 ARG builder_image=docker.io/library/golang:1.23.4 -ARG BASEIMAGE=gcr.io/distroless/static:nonroot-amd64 +ARG BASEIMAGE=gcr.io/distroless/static:nonroot-${TARGETARCH} + FROM ${builder_image} AS builder + +ARG TARGETOS +ARG TARGETARCH +ENV GOOS=$TARGETOS +ENV GOARCH=$TARGETARCH + RUN git clone https://github.com/kubernetes/autoscaler /src/autoscaler \ && cd /src/autoscaler/cluster-autoscaler \ && git checkout cluster-autoscaler-1.32.0 @@ -14,6 +21,8 @@ RUN make build FROM $BASEIMAGE LABEL maintainer="Marcin Wielgus " -COPY --from=builder /src/autoscaler/cluster-autoscaler/cluster-autoscaler-amd64 /cluster-autoscaler +ARG TARGETARCH + +COPY --from=builder /src/autoscaler/cluster-autoscaler/cluster-autoscaler-${TARGETARCH} /cluster-autoscaler WORKDIR / CMD ["/cluster-autoscaler"] diff --git a/packages/apps/kubernetes/images/kubevirt-cloud-provider/Dockerfile b/packages/apps/kubernetes/images/kubevirt-cloud-provider/Dockerfile index 97760bd7..0e2c3a2f 100644 --- a/packages/apps/kubernetes/images/kubevirt-cloud-provider/Dockerfile +++ b/packages/apps/kubernetes/images/kubevirt-cloud-provider/Dockerfile @@ -1,5 +1,10 @@ # Source: https://github.com/kubevirt/cloud-provider-kubevirt/blob/main/build/images/kubevirt-cloud-controller-manager/Dockerfile -FROM --platform=linux/amd64 golang:1.20.6 AS builder +FROM golang:1.20.6 AS builder + +ARG TARGETOS +ARG TARGETARCH +ENV GOOS=$TARGETOS +ENV GOARCH=$TARGETARCH RUN git clone https://github.com/kubevirt/cloud-provider-kubevirt /go/src/kubevirt.io/cloud-provider-kubevirt \ && cd /go/src/kubevirt.io/cloud-provider-kubevirt \ @@ -14,7 +19,7 @@ RUN go get 'k8s.io/endpointslice/util@v0.28' 'k8s.io/apiserver@v0.28' RUN go mod tidy RUN go mod vendor -RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor -ldflags="-s -w" -o bin/kubevirt-cloud-controller-manager ./cmd/kubevirt-cloud-controller-manager +RUN CGO_ENABLED=0 go build -mod=vendor -ldflags="-s -w" -o bin/kubevirt-cloud-controller-manager ./cmd/kubevirt-cloud-controller-manager FROM registry.access.redhat.com/ubi9/ubi-micro COPY --from=builder /go/src/kubevirt.io/cloud-provider-kubevirt/bin/kubevirt-cloud-controller-manager /bin/kubevirt-cloud-controller-manager diff --git a/packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile b/packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile index b53c7b3d..27dda789 100644 --- a/packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile +++ b/packages/apps/kubernetes/images/kubevirt-csi-driver/Dockerfile @@ -5,6 +5,11 @@ RUN git clone https://github.com/kubevirt/csi-driver /src/kubevirt-csi-driver \ && cd /src/kubevirt-csi-driver \ && git checkout 35836e0c8b68d9916d29a838ea60cdd3fc6199cf +ARG TARGETOS +ARG TARGETARCH +ENV GOOS=$TARGETOS +ENV GOARCH=$TARGETARCH + WORKDIR /src/kubevirt-csi-driver RUN make build diff --git a/packages/apps/kubernetes/images/ubuntu-container-disk/Dockerfile b/packages/apps/kubernetes/images/ubuntu-container-disk/Dockerfile index 395adeb0..f5a7d54d 100644 --- a/packages/apps/kubernetes/images/ubuntu-container-disk/Dockerfile +++ b/packages/apps/kubernetes/images/ubuntu-container-disk/Dockerfile @@ -1,5 +1,5 @@ # TODO: Here we use ubuntu:22.04, as guestfish has some network issues running in ubuntu:24.04 -FROM ubuntu:22.04 as guestfish +FROM ubuntu:22.04 AS guestfish ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update \ @@ -8,15 +8,17 @@ RUN apt-get update \ linux-image-generic \ wget \ make \ - bash-completion \ - && apt-get clean + bash-completion WORKDIR /build -FROM guestfish as builder +FROM guestfish AS builder + +ARG TARGETOS +ARG TARGETARCH # noble is a code name for the Ubuntu 24.04 LTS release -RUN wget -O image.img https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img --show-progress --output-file /dev/stdout --progress=dot:giga 2>/dev/null +RUN wget -O image.img https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-${TARGETARCH}.img --show-progress --output-file /dev/stdout --progress=dot:giga 2>/dev/null ARG KUBERNETES_VERSION @@ -29,19 +31,21 @@ RUN qemu-img resize image.img 5G \ && guestfish --remote command "resize2fs /dev/sda1" \ # docker repo && guestfish --remote sh "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg" \ - && guestfish --remote sh 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list' \ + && guestfish --remote sh 'echo "deb [signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list' \ # kubernetes repo && guestfish --remote sh "curl -fsSL https://pkgs.k8s.io/core:/stable:/${KUBERNETES_VERSION}/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg" \ && guestfish --remote sh "echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/${KUBERNETES_VERSION}/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list" \ + && guestfish --remote command "apt-get check -q" \ # install containerd - && guestfish --remote command "apt-get update -y" \ - && guestfish --remote command "apt-get install -y containerd.io" \ + && guestfish --remote command "apt-get update -q" \ + && guestfish --remote command "apt-get install -yq containerd.io" \ # configure containerd && guestfish --remote command "mkdir -p /etc/containerd" \ && guestfish --remote sh "containerd config default | tee /etc/containerd/config.toml" \ && guestfish --remote command "sed -i '/SystemdCgroup/ s/=.*/= true/' /etc/containerd/config.toml" \ + && guestfish --remote command "containerd config dump >/dev/null" \ # install kubernetes - && guestfish --remote command "apt-get install -y kubelet kubeadm" \ + && guestfish --remote command "apt-get install -yq kubelet kubeadm" \ # clean apt cache && guestfish --remote sh 'apt-get clean && rm -rf /var/lib/apt/lists/*' \ # write system configuration diff --git a/packages/apps/mysql/Makefile b/packages/apps/mysql/Makefile index d32df5dd..8bc17337 100644 --- a/packages/apps/mysql/Makefile +++ b/packages/apps/mysql/Makefile @@ -7,8 +7,10 @@ generate: readme-generator -v values.yaml -s values.schema.json -r README.md image: - docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/mariadb-backup \ + docker buildx build images/mariadb-backup \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/mariadb-backup:$(call settag,$(MARIADB_BACKUP_TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/mariadb-backup:latest \ --cache-to type=inline \ diff --git a/packages/apps/postgres/Makefile b/packages/apps/postgres/Makefile index 78639877..c0a894c0 100644 --- a/packages/apps/postgres/Makefile +++ b/packages/apps/postgres/Makefile @@ -7,8 +7,10 @@ generate: readme-generator -v values.yaml -s values.schema.json -r README.md image: - docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/postgres-backup \ + docker buildx build images/postgres-backup \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/postgres-backup:$(call settag,$(POSTGRES_BACKUP_TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/postgres-backup:latest \ --cache-to type=inline \ diff --git a/packages/core/testing/Makefile b/packages/core/testing/Makefile index 7b1eb049..b620c947 100755 --- a/packages/core/testing/Makefile +++ b/packages/core/testing/Makefile @@ -17,6 +17,8 @@ image: image-e2e-sandbox image-e2e-sandbox: docker buildx build -f images/e2e-sandbox/Dockerfile ../../.. \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/e2e-sandbox:$(call settag,$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/e2e-sandbox:latest \ --cache-to type=inline \ diff --git a/packages/core/testing/images/e2e-sandbox/Dockerfile b/packages/core/testing/images/e2e-sandbox/Dockerfile index 8318e982..3b25dfc6 100755 --- a/packages/core/testing/images/e2e-sandbox/Dockerfile +++ b/packages/core/testing/images/e2e-sandbox/Dockerfile @@ -4,14 +4,16 @@ ARG KUBECTL_VERSION=1.32.0 ARG TALOSCTL_VERSION=1.9.5 ARG HELM_VERSION=3.16.4 -RUN apt-get update -RUN apt-get -y install genisoimage qemu-kvm qemu-utils iproute2 iptables wget xz-utils netcat curl jq make git -RUN curl -LO "https://github.com/siderolabs/talos/releases/download/v${TALOSCTL_VERSION}/talosctl-linux-amd64" \ - && chmod +x talosctl-linux-amd64 \ - && mv talosctl-linux-amd64 /usr/local/bin/talosctl -RUN curl -LO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \ - && chmod +x kubectl \ - && mv kubectl /usr/local/bin/kubectl -RUN curl -sSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash -s - --version "v${HELM_VERSION}" -RUN wget https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 -O /usr/local/bin/yq && chmod +x /usr/local/bin/yq -RUN curl -s https://fluxcd.io/install.sh | bash +ARG TARGETOS +ARG TARGETARCH + +RUN apt update -q +RUN apt install -yq --no-install-recommends ca-certificates qemu-kvm qemu-utils iproute2 iptables wget xz-utils netcat curl jq make git +RUN curl -sSL "https://github.com/siderolabs/talos/releases/download/v${TALOSCTL_VERSION}/talosctl-${TARGETOS}-${TARGETARCH}" -o /usr/local/bin/talosctl \ + && chmod +x /usr/local/bin/talosctl +RUN curl -sSL "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/${TARGETOS}/${TARGETARCH}/kubectl" -o /usr/local/bin/kubectl \ + && chmod +x /usr/local/bin/kubectl +RUN curl -sSL "https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3" | bash -s - --version "v${HELM_VERSION}" +RUN curl -sSL "https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_${TARGETOS}_${TARGETARCH}" -o /usr/local/bin/yq \ + && chmod +x /usr/local/bin/yq +RUN curl -sSL "https://fluxcd.io/install.sh" | bash diff --git a/packages/extra/monitoring/Makefile b/packages/extra/monitoring/Makefile index dd5b4386..e2b8d330 100644 --- a/packages/extra/monitoring/Makefile +++ b/packages/extra/monitoring/Makefile @@ -13,8 +13,10 @@ generate: rm -f values.schema.json.tmp image: - docker buildx build --platform linux/amd64 images/grafana \ + docker buildx build images/grafana \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/grafana:$(call settag,$(GRAFANA_TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/grafana:latest \ --cache-to type=inline \ diff --git a/packages/system/bucket/Makefile b/packages/system/bucket/Makefile index 125e2e98..1f8d34b2 100644 --- a/packages/system/bucket/Makefile +++ b/packages/system/bucket/Makefile @@ -6,14 +6,15 @@ include ../../../scripts/common-envs.mk include ../../../scripts/package.mk update: - rm -rf charts - helm pull oci://ghcr.io/aenix-io/charts/etcd-operator --untar --untardir charts + @echo Nothing to update image: image-s3manager image-s3manager: - docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/s3manager \ + docker buildx build images/s3manager \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/s3manager:$(call settag,$(S3MANAGER_TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/s3manager:latest \ --cache-to type=inline \ diff --git a/packages/system/bucket/images/s3manager/Dockerfile b/packages/system/bucket/images/s3manager/Dockerfile index de59229a..179acead 100644 --- a/packages/system/bucket/images/s3manager/Dockerfile +++ b/packages/system/bucket/images/s3manager/Dockerfile @@ -1,11 +1,15 @@ # Source: https://github.com/cloudlena/s3manager/blob/main/Dockerfile FROM docker.io/library/golang:1 AS builder + +ARG TARGETOS +ARG TARGETARCH + WORKDIR /usr/src/app RUN wget -O- https://github.com/cloudlena/s3manager/archive/9a7c8e446b422f8973b8c461990f39fdafee9c27.tar.gz | tar -xzf- --strip 1 ADD cozystack.patch / RUN git apply /cozystack.patch -RUN CGO_ENABLED=0 go build -ldflags="-s -w" -a -installsuffix cgo -o bin/s3manager +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -ldflags="-s -w" -a -installsuffix cgo -o bin/s3manager FROM docker.io/library/alpine:latest WORKDIR /usr/src/app diff --git a/packages/system/bucket/values.yaml b/packages/system/bucket/values.yaml index 4b57a59c..e1499c6e 100644 --- a/packages/system/bucket/values.yaml +++ b/packages/system/bucket/values.yaml @@ -1 +1 @@ -bucketName: "" +bucketName: "cozystack" diff --git a/packages/system/cilium/Makefile b/packages/system/cilium/Makefile index e96d20ef..72502d12 100644 --- a/packages/system/cilium/Makefile +++ b/packages/system/cilium/Makefile @@ -18,6 +18,8 @@ update: image: docker buildx build images/cilium \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/cilium:$(call settag,$(CILIUM_TAG)) \ --tag $(REGISTRY)/cilium:$(call settag,$(CILIUM_TAG)-$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/cilium:latest \ diff --git a/packages/system/cozystack-api/Makefile b/packages/system/cozystack-api/Makefile index 053fe329..66853833 100644 --- a/packages/system/cozystack-api/Makefile +++ b/packages/system/cozystack-api/Makefile @@ -9,6 +9,8 @@ image: image-cozystack-api image-cozystack-api: docker buildx build -f images/cozystack-api/Dockerfile ../../.. \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/cozystack-api:$(call settag,$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/cozystack-api:latest \ --cache-to type=inline \ diff --git a/packages/system/cozystack-api/images/cozystack-api/Dockerfile b/packages/system/cozystack-api/images/cozystack-api/Dockerfile index 6b8e5cc1..c3f90f01 100644 --- a/packages/system/cozystack-api/images/cozystack-api/Dockerfile +++ b/packages/system/cozystack-api/images/cozystack-api/Dockerfile @@ -1,16 +1,19 @@ -FROM golang:1.23-alpine as builder +FROM golang:1.23-alpine AS builder + +ARG TARGETOS +ARG TARGETARCH WORKDIR /workspace COPY go.mod go.sum ./ -RUN go mod download +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go mod download COPY api api/ COPY pkg pkg/ COPY cmd cmd/ COPY internal internal/ -RUN CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o /cozystack-api cmd/cozystack-api/main.go +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o /cozystack-api cmd/cozystack-api/main.go FROM scratch diff --git a/packages/system/cozystack-controller/images/cozystack-controller/Dockerfile b/packages/system/cozystack-controller/images/cozystack-controller/Dockerfile index c289c8d2..b44d5ac8 100644 --- a/packages/system/cozystack-controller/images/cozystack-controller/Dockerfile +++ b/packages/system/cozystack-controller/images/cozystack-controller/Dockerfile @@ -1,16 +1,19 @@ -FROM golang:1.23-alpine as builder +FROM golang:1.23-alpine AS builder + +ARG TARGETOS +ARG TARGETARCH WORKDIR /workspace COPY go.mod go.sum ./ -RUN go mod download +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go mod download COPY api api/ COPY pkg pkg/ COPY cmd cmd/ COPY internal internal/ -RUN CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o /cozystack-controller cmd/cozystack-controller/main.go +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -ldflags="-extldflags=-static" -o /cozystack-controller cmd/cozystack-controller/main.go FROM scratch 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 \ diff --git a/packages/system/kamaji/Makefile b/packages/system/kamaji/Makefile index 0956527d..aa864c1a 100644 --- a/packages/system/kamaji/Makefile +++ b/packages/system/kamaji/Makefile @@ -14,6 +14,8 @@ update: image: docker buildx build images/kamaji \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/kamaji:$(call settag,$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/kamaji:latest \ --cache-to type=inline \ diff --git a/packages/system/kamaji/images/kamaji/Dockerfile b/packages/system/kamaji/images/kamaji/Dockerfile index b607756b..1646262a 100644 --- a/packages/system/kamaji/images/kamaji/Dockerfile +++ b/packages/system/kamaji/images/kamaji/Dockerfile @@ -1,8 +1,9 @@ # Build the manager binary FROM golang:1.24 as builder -ARG VERSION=edge-25.4.1 -ARG TARGETOS TARGETARCH +ARG VERSION=edge-25.3.2 +ARG TARGETOS +ARG TARGETARCH WORKDIR /workspace @@ -11,7 +12,7 @@ RUN curl -sSL https://github.com/clastix/kamaji/archive/refs/tags/${VERSION}.tar COPY patches /patches RUN git apply /patches/*.diff -RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build \ +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build \ -ldflags "-X github.com/clastix/kamaji/internal.GitRepo=$GIT_REPO -X github.com/clastix/kamaji/internal.GitTag=$GIT_LAST_TAG -X github.com/clastix/kamaji/internal.GitCommit=$GIT_HEAD_COMMIT -X github.com/clastix/kamaji/internal.GitDirty=$GIT_MODIFIED -X github.com/clastix/kamaji/internal.BuildTime=$BUILD_DATE" \ -a -o kamaji main.go @@ -22,4 +23,4 @@ WORKDIR / COPY --from=builder /workspace/kamaji . USER 65532:65532 -ENTRYPOINT ["/kamaji"] +ENTRYPOINT ["/kamaji"] \ No newline at end of file diff --git a/packages/system/kubeovn-webhook/Makefile b/packages/system/kubeovn-webhook/Makefile index 2605ca5e..76bf5f5a 100644 --- a/packages/system/kubeovn-webhook/Makefile +++ b/packages/system/kubeovn-webhook/Makefile @@ -7,6 +7,8 @@ include ../../../scripts/package.mk image: docker buildx build images/kubeovn-webhook \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/kubeovn-webhook:$(call settag,$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/kubeovn-webhook:latest \ --cache-to type=inline \ diff --git a/packages/system/kubeovn-webhook/images/kubeovn-webhook/Dockerfile b/packages/system/kubeovn-webhook/images/kubeovn-webhook/Dockerfile index 337e72e4..73d5e99b 100644 --- a/packages/system/kubeovn-webhook/images/kubeovn-webhook/Dockerfile +++ b/packages/system/kubeovn-webhook/images/kubeovn-webhook/Dockerfile @@ -1,11 +1,14 @@ -FROM golang:1.23 as builder +FROM golang:1.23 AS builder + +ARG TARGETOS +ARG TARGETARCH WORKDIR /app COPY go.mod go.sum ./ -RUN go mod download +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go mod download COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -o webhook . +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o webhook . FROM alpine:3.21.3 WORKDIR /app diff --git a/packages/system/kubeovn/Makefile b/packages/system/kubeovn/Makefile index be01e9c5..62f0afae 100644 --- a/packages/system/kubeovn/Makefile +++ b/packages/system/kubeovn/Makefile @@ -19,6 +19,8 @@ update: image: docker buildx build images/kubeovn \ --provenance false \ + --builder=$(BUILDER) \ + --platform=$(PLATFORM) \ --tag $(REGISTRY)/kubeovn:$(call settag,$(KUBEOVN_TAG)) \ --tag $(REGISTRY)/kubeovn:$(call settag,$(KUBEOVN_TAG)-$(TAG)) \ --cache-from type=registry,ref=$(REGISTRY)/kubeovn:latest \