diff --git a/dev/tasks/build-images b/dev/tasks/build-images new file mode 100755 index 000000000..a60449bba --- /dev/null +++ b/dev/tasks/build-images @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Copyright 2024 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +REPO_ROOT="$(git rev-parse --show-toplevel)" +cd "${REPO_ROOT}" + +if [[ -z "${IMAGE_PREFIX:-}" ]]; then + echo "IMAGE_PREFIX is not set" + exit 1 +fi + +IMAGE_TAG=${IMAGE_PREFIX}/etcd-manager-minimal:latest + +if [[ -z "${BUILD_ARGS:-}" ]]; then + BUILD_ARGS="--load" +fi +echo "Building image ${IMAGE_TAG} with args ${BUILD_ARGS:-}" + +docker buildx build ${BUILD_ARGS} -t ${IMAGE_TAG} -f ./images/etcd-manager-minimal/Dockerfile . diff --git a/images/etcd-manager-minimal/Dockerfile b/images/etcd-manager-minimal/Dockerfile new file mode 100644 index 000000000..c4dd171f9 --- /dev/null +++ b/images/etcd-manager-minimal/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:1.22 AS builder + +RUN mkdir /workspace +WORKDIR /workspace +COPY go.mod go.mod +COPY go.sum go.sum +RUN go mod download +RUN CGO_ENABLED=0 go build k8s.io/klog/v2 go.etcd.io/etcd/client/v3 + +COPY cmd cmd +COPY pkg pkg + + +RUN CGO_ENABLED=0 go build -v -o /etcd-manager ./cmd/etcd-manager + +#FROM scratch +# We at least need debian12 for sh, becaue we currently launch with a shell for log files +#FROM gcr.io/distroless/static-debian12:latest +FROM debian:12 + +COPY --from=builder /etcd-manager /etcd-manager + +ENTRYPOINT [ "/etcd-manager" ] \ No newline at end of file