From dcc8fe7623bb8fc1634cf8aa2d192d0ea8b4d888 Mon Sep 17 00:00:00 2001 From: kpango Date: Wed, 7 Feb 2024 20:28:49 +0900 Subject: [PATCH] Go source install Signed-off-by: kpango --- Makefile.d/docker.mk | 11 +++-------- Makefile.d/functions.mk | 7 ++++--- dockers/agent/core/faiss/Dockerfile | 16 +++++++++++----- dockers/agent/core/ngt/Dockerfile | 16 +++++++++++----- dockers/agent/sidecar/Dockerfile | 16 +++++++++++----- dockers/ci/base/Dockerfile | 19 ++++++++++++------- dockers/discoverer/k8s/Dockerfile | 16 +++++++++++----- dockers/gateway/filter/Dockerfile | 14 ++++++++++---- dockers/gateway/lb/Dockerfile | 16 +++++++++++----- dockers/gateway/mirror/Dockerfile | 16 +++++++++++----- dockers/index/job/correction/Dockerfile | 16 +++++++++++----- dockers/index/job/creation/Dockerfile | 16 +++++++++++----- .../index/job/readreplica/rotate/Dockerfile | 16 +++++++++++----- dockers/index/job/save/Dockerfile | 16 +++++++++++----- dockers/manager/index/Dockerfile | 16 +++++++++++----- dockers/operator/helm/Dockerfile | 15 +++++++++++---- dockers/tools/benchmark/job/Dockerfile | 16 +++++++++++----- dockers/tools/benchmark/operator/Dockerfile | 18 +++++++++++------- dockers/tools/cli/loadtest/Dockerfile | 16 +++++++++++----- 19 files changed, 194 insertions(+), 98 deletions(-) diff --git a/Makefile.d/docker.mk b/Makefile.d/docker.mk index 2c4ba337369..3eec0178596 100644 --- a/Makefile.d/docker.mk +++ b/Makefile.d/docker.mk @@ -93,14 +93,9 @@ docker/name/agent-faiss: .PHONY: docker/build/agent-faiss ## build agent-faiss image docker/build/agent-faiss: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/agent/core/faiss/Dockerfile \ - -t $(ORG)/vald-agent-faiss:$(TAG) . \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ - --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \ - --build-arg MAINTAINER=$(MAINTAINER) + @make DOCKERFILE="$(ROOTDIR)/dockers/agent/core/faiss/Dockerfile" \ + IMAGE=$(AGENT_IMAGE) \ + docker/build/image .PHONY: docker/name/agent-sidecar docker/name/agent-sidecar: diff --git a/Makefile.d/functions.mk b/Makefile.d/functions.mk index eb5ecd56739..753349cd97f 100644 --- a/Makefile.d/functions.mk +++ b/Makefile.d/functions.mk @@ -57,16 +57,17 @@ define go-build echo $(PBGOS) echo $(shell find $(ROOTDIR)/cmd/$1 -type f -name '*.go' -not -name '*_test.go' -not -name 'doc.go') echo $(shell find $(ROOTDIR)/pkg/$1 -type f -name '*.go' -not -name '*_test.go' -not -name 'doc.go') - CGO_CXXFLAGS="-g -Ofast -march=native" \ + CFLAGS="$(CFLAGS)" \ + CXXFLAGS="$(CXXFLAGS)" \ CGO_ENABLED=$(CGO_ENABLED) \ + CGO_CXXFLAGS="-g -Ofast -march=native" \ CGO_FFLAGS="-g -Ofast -march=native" \ CGO_LDFLAGS="-g -Ofast -march=native" \ - CFLAGS="$(CFLAGS)" \ - CXXFLAGS="$(CXXFLAGS)" \ GO111MODULE=on \ GOARCH=$(GOARCH) \ GOOS=$(GOOS) \ GOPRIVATE=$(GOPRIVATE) \ + GO_VERSION=$(GO_VERSION) \ go build \ --ldflags "-w $2 \ -extldflags '-static $3' \ diff --git a/dockers/agent/core/faiss/Dockerfile b/dockers/agent/core/faiss/Dockerfile index a23c3ba890c..0ef126b72e0 100644 --- a/dockers/agent/core/faiss/Dockerfile +++ b/dockers/agent/core/faiss/Dockerfile @@ -15,15 +15,13 @@ # limitations under the License. # -ARG GO_VERSION=latest # ARG DISTROLESS_IMAGE=gcr.io/distroless/static # ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -55,8 +53,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/agent/core/ngt/Dockerfile b/dockers/agent/core/ngt/Dockerfile index b14096fa774..697441a4cef 100644 --- a/dockers/agent/core/ngt/Dockerfile +++ b/dockers/agent/core/ngt/Dockerfile @@ -15,17 +15,15 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ARG TARGETARCH ARG TARGETOS +ARG GO_VERSION ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -57,8 +55,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/agent/sidecar/Dockerfile b/dockers/agent/sidecar/Dockerfile index ad7a7cd5fa4..4b6151dc6a3 100644 --- a/dockers/agent/sidecar/Dockerfile +++ b/dockers/agent/sidecar/Dockerfile @@ -15,15 +15,13 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -50,8 +48,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/ci/base/Dockerfile b/dockers/ci/base/Dockerfile index b70ff6d4791..f1028affd53 100644 --- a/dockers/ci/base/Dockerfile +++ b/dockers/ci/base/Dockerfile @@ -15,14 +15,12 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder LABEL maintainer="${MAINTAINER}" +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -34,10 +32,6 @@ ENV GOROOT /opt/go ENV GOPATH /go ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin:/usr/local/bin -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p $GOPATH/src - - RUN sysctl -w net.ipv6.conf.all.disable_ipv6=1 \ && sysctl -w net.ipv6.conf.default.disable_ipv6=1 \ && sysctl -w net.ipv6.conf.lo.disable_ipv6=1 @@ -68,6 +62,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" + WORKDIR ${GOPATH}/src/github.com/vdaas/vald ENV ROOTDIR . diff --git a/dockers/discoverer/k8s/Dockerfile b/dockers/discoverer/k8s/Dockerfile index 4bb2e17309f..0774ca28253 100644 --- a/dockers/discoverer/k8s/Dockerfile +++ b/dockers/discoverer/k8s/Dockerfile @@ -15,15 +15,13 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -50,8 +48,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/gateway/filter/Dockerfile b/dockers/gateway/filter/Dockerfile index 7cfb950745e..1d52a439f8b 100644 --- a/dockers/gateway/filter/Dockerfile +++ b/dockers/gateway/filter/Dockerfile @@ -20,8 +20,6 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ARG TARGETARCH @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/gateway/lb/Dockerfile b/dockers/gateway/lb/Dockerfile index 2f0dbcc4ea8..c4d1ee9f7c6 100644 --- a/dockers/gateway/lb/Dockerfile +++ b/dockers/gateway/lb/Dockerfile @@ -15,15 +15,13 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/gateway/mirror/Dockerfile b/dockers/gateway/mirror/Dockerfile index 67d61c45b24..59740ebf549 100644 --- a/dockers/gateway/mirror/Dockerfile +++ b/dockers/gateway/mirror/Dockerfile @@ -14,15 +14,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -48,8 +46,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} diff --git a/dockers/index/job/correction/Dockerfile b/dockers/index/job/correction/Dockerfile index 7d5b5530fa1..b4b482816a9 100644 --- a/dockers/index/job/correction/Dockerfile +++ b/dockers/index/job/correction/Dockerfile @@ -15,15 +15,13 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/index/job/creation/Dockerfile b/dockers/index/job/creation/Dockerfile index 18954b23e6e..2dbce88b9a5 100644 --- a/dockers/index/job/creation/Dockerfile +++ b/dockers/index/job/creation/Dockerfile @@ -15,15 +15,13 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/index/job/readreplica/rotate/Dockerfile b/dockers/index/job/readreplica/rotate/Dockerfile index 79ddda23cc1..25bd5da7b3f 100644 --- a/dockers/index/job/readreplica/rotate/Dockerfile +++ b/dockers/index/job/readreplica/rotate/Dockerfile @@ -15,15 +15,13 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/index/job/save/Dockerfile b/dockers/index/job/save/Dockerfile index 8e328b32008..01806240870 100644 --- a/dockers/index/job/save/Dockerfile +++ b/dockers/index/job/save/Dockerfile @@ -15,15 +15,13 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/manager/index/Dockerfile b/dockers/manager/index/Dockerfile index d1660dd0c03..46cb79111f0 100644 --- a/dockers/manager/index/Dockerfile +++ b/dockers/manager/index/Dockerfile @@ -15,15 +15,13 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/operator/helm/Dockerfile b/dockers/operator/helm/Dockerfile index 20d4c2046ba..eb4b646b954 100644 --- a/dockers/operator/helm/Dockerfile +++ b/dockers/operator/helm/Dockerfile @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG OPERATOR_SDK_VERSION @@ -29,9 +28,9 @@ ARG TARGETOS # skipcq: DOK-DL3026 FROM --platform=${BUILDPLATFORM} quay.io/operator-framework/helm-operator:${OPERATOR_SDK_VERSION} AS operator -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG OPERATOR_SDK_VERSION ARG VERSION ARG GROUP @@ -69,8 +68,16 @@ RUN apt-get clean \ /var/cache/* \ && apt-get autoremove -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" RUN { \ echo "---"; \ diff --git a/dockers/tools/benchmark/job/Dockerfile b/dockers/tools/benchmark/job/Dockerfile index 0e0bf3af9c7..f03829f8dfb 100644 --- a/dockers/tools/benchmark/job/Dockerfile +++ b/dockers/tools/benchmark/job/Dockerfile @@ -15,7 +15,6 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG ZLIB_VERSION ARG HDF5_VERSION ARG DISTROLESS_IMAGE=gcr.io/distroless/static @@ -23,10 +22,9 @@ ARG DISTROLESS_IMAGE_TAG=nonroot ARG UPX_OPTIONS=-9 ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG UPX_OPTIONS ARG ZLIB_VERSION ARG HDF5_VERSION @@ -78,8 +76,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && make install \ && ldconfig -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/tools/benchmark/operator/Dockerfile b/dockers/tools/benchmark/operator/Dockerfile index 8b8c8ba2d24..f49a54820bf 100644 --- a/dockers/tools/benchmark/operator/Dockerfile +++ b/dockers/tools/benchmark/operator/Dockerfile @@ -15,16 +15,14 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG UPX_OPTIONS=-9 ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -51,10 +49,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -RUN mkdir -p ${GOPATH}/src - -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d . diff --git a/dockers/tools/cli/loadtest/Dockerfile b/dockers/tools/cli/loadtest/Dockerfile index 0fe4ec019c8..a8b427bc3e8 100644 --- a/dockers/tools/cli/loadtest/Dockerfile +++ b/dockers/tools/cli/loadtest/Dockerfile @@ -15,13 +15,11 @@ # limitations under the License. # -ARG GO_VERSION=latest ARG MAINTAINER="vdaas.org vald team " -FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang - FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder +ARG GO_VERSION ARG TARGETARCH ARG TARGETOS @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -COPY --from=golang /usr/local/go $GOROOT -RUN mkdir -p "$GOPATH/src" +WORKDIR /opt +RUN set -x && cd "$(mktemp -d)" \ + && BIN_NAME="go" \ + && TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \ + && curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \ + && tar zxf "${TAR_NAME}" \ + && rm "${TAR_NAME}" \ + && mv ${BIN_NAME} ${GOROOT} \ + && ${BIN_NAME} version \ + && mkdir -p "${GOPATH}/src" WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d COPY Makefile.d .