From 472338b9b8234e08a5b55a15327be1aff15916fd Mon Sep 17 00:00:00 2001 From: David Benque Date: Fri, 30 Jun 2023 13:45:03 +0200 Subject: [PATCH 1/2] dockerfile and CI --- .gitlab-ci.yml | 15 +++++++++++++++ vertical-pod-autoscaler/Dockerfile | 27 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 vertical-pod-autoscaler/Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000000..88423e900c57 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,15 @@ +include: https://gitlab-templates.ddbuild.io/compute-delivery/v2/compute-delivery.yml + +test: + stage: verify + tags: [ "arch:amd64" ] + image: registry.ddbuild.io/images/mirror/golang:1.20 + script: + - echo "TODO test" + +build-docker-image: + variables: + EXTRA_ARGS: "-f vertical-pod-autoscaler/Dockerfile" + + extends: .build-docker-image + diff --git a/vertical-pod-autoscaler/Dockerfile b/vertical-pod-autoscaler/Dockerfile new file mode 100644 index 000000000000..daf58e1fd31b --- /dev/null +++ b/vertical-pod-autoscaler/Dockerfile @@ -0,0 +1,27 @@ +ARG BASE_IMAGE + +FROM --platform=$BUILDPLATFORM golang:1.19 AS builder +WORKDIR /go/src/k8s.io/autoscaler +COPY . . +ARG TARGETARCH +ENV GO111MODULE "on" +ENV GOARCH=${TARGETARCH} + +WORKDIR /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender +RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-recommender --ldflags "-s" + +WORKDIR /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender-external +RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-recommender-external-metrics --ldflags "-s" + +WORKDIR /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/admission-controller +RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-admission-controller --ldflags "-s" + +WORKDIR /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/updater +RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-updater --ldflags "-s" + +FROM $BASE_IMAGE + +COPY --from=builder /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/vpa-recommender /usr/local/bin/vpa-recommender +COPY --from=builder /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender-external/vpa-recommender-external-metrics /usr/local/bin/vpa-recommender-external-metrics +COPY --from=builder /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/admission-controller/vpa-admission-controller /usr/local/bin/vpa-admission-controller +COPY --from=builder /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/updater/vpa-updater /usr/local/bin/vpa-updater From 4cf9e0517c2b5849a428d962d13d875b7ee001a3 Mon Sep 17 00:00:00 2001 From: David Benque Date: Wed, 5 Jul 2023 16:31:19 +0200 Subject: [PATCH 2/2] [vpa] buildvcs=false --- vertical-pod-autoscaler/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vertical-pod-autoscaler/Dockerfile b/vertical-pod-autoscaler/Dockerfile index daf58e1fd31b..3aea01ae80e6 100644 --- a/vertical-pod-autoscaler/Dockerfile +++ b/vertical-pod-autoscaler/Dockerfile @@ -8,16 +8,16 @@ ENV GO111MODULE "on" ENV GOARCH=${TARGETARCH} WORKDIR /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender -RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-recommender --ldflags "-s" +RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-recommender -buildvcs=false --ldflags "-s" WORKDIR /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender-external -RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-recommender-external-metrics --ldflags "-s" +RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-recommender-external-metrics -buildvcs=false --ldflags "-s" WORKDIR /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/admission-controller -RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-admission-controller --ldflags "-s" +RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-admission-controller -buildvcs=false --ldflags "-s" WORKDIR /go/src/k8s.io/autoscaler/vertical-pod-autoscaler/pkg/updater -RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-updater --ldflags "-s" +RUN env CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=linux go build -o vpa-updater -buildvcs=false --ldflags "-s" FROM $BASE_IMAGE