sigs.k8s.io/controller-tools@v0.15.1-0.20240515195456-85686cb69316/hack/envtest/linux/Dockerfile (about) 1 # Copyright 2018 The Kubernetes Authors. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 ARG GO_VERSION 16 FROM golang:${GO_VERSION} as builder 17 18 # Version and platform args. 19 ARG KUBERNETES_VERSION 20 ARG ETCD_VERSION 21 ARG OS=linux 22 ARG ARCH 23 24 # Tools path. 25 ENV DEST=/controller-tools/envtest 26 27 # Install dependencies. 28 RUN apt update && \ 29 apt install unzip rsync -y && \ 30 mkdir -p $DEST 31 32 # kube-apiserver 33 RUN curl -sfLO https://dl.k8s.io/${KUBERNETES_VERSION}/bin/${OS}/${ARCH}/kube-apiserver && \ 34 chmod +x kube-apiserver && \ 35 cp kube-apiserver $DEST 36 37 # kubectl 38 RUN curl -sfLO https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/${OS}/${ARCH}/kubectl && \ 39 chmod +x kubectl && \ 40 cp kubectl $DEST 41 42 # etcd 43 ENV ETCD_BASE_NAME=etcd-${ETCD_VERSION}-${OS}-${ARCH} 44 RUN curl -sfLO https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/${ETCD_BASE_NAME}.tar.gz && \ 45 tar xzf ${ETCD_BASE_NAME}.tar.gz && \ 46 cp ${ETCD_BASE_NAME}/etcd $DEST 47 48 # Package into tarball. 49 RUN tar -czvf /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz $DEST 50 RUN sha512sum /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz > /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512 51 52 # Build the final image with the binaries. 53 FROM scratch 54 ARG OS 55 ARG ARCH 56 ARG KUBERNETES_VERSION 57 COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz / 58 COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512 /