sigs.k8s.io/controller-tools@v0.15.1-0.20240515195456-85686cb69316/hack/envtest/darwin/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=darwin
    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  WORKDIR /kubernetes
    34  RUN git clone https://github.com/kubernetes/kubernetes . --depth=1 -b ${KUBERNETES_VERSION}
    35  ENV CGO_ENABLED=0
    36  ENV KUBE_BUILD_PLATFORMS=${OS}/${ARCH}
    37  RUN make WHAT=cmd/kube-apiserver && \
    38      cp _output/local/bin/${KUBE_BUILD_PLATFORMS}/kube-apiserver $DEST
    39  
    40  # kubectl
    41  RUN /bin/bash -x -c ' \
    42      { curl -sfLO https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/${OS}/${ARCH}/kubectl && \
    43        chmod +x kubectl && \
    44        cp kubectl $DEST; } || \
    45      { make WHAT=cmd/kubectl && \
    46        cp _output/local/bin/${KUBE_BUILD_PLATFORMS}/kubectl $DEST; }'
    47  
    48  # etcd
    49  ENV ETCD_BASE_NAME=etcd-${ETCD_VERSION}-${OS}-${ARCH}
    50  RUN curl -sfLO https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/${ETCD_BASE_NAME}.zip && \
    51      unzip -o ${ETCD_BASE_NAME}.zip && \
    52      cp ${ETCD_BASE_NAME}/etcd $DEST
    53  
    54  # Package into tarball.
    55  RUN tar -czvf /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz $DEST
    56  RUN sha512sum /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz > /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512
    57  
    58  # Build the final image with the binaries.
    59  FROM scratch
    60  ARG OS
    61  ARG ARCH
    62  ARG KUBERNETES_VERSION
    63  COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz /
    64  COPY --from=builder /envtest-${KUBERNETES_VERSION}-${OS}-${ARCH}.tar.gz.sha512 /