k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/images/bootstrap/Dockerfile (about) 1 # Copyright 2017 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 # Includes basic workspace setup, with gcloud and a bootstrap runner 16 17 FROM debian:bookworm 18 19 WORKDIR /workspace 20 RUN mkdir -p /workspace 21 ENV WORKSPACE=/workspace \ 22 TERM=xterm 23 24 # add env we can debug with the image name:tag 25 ARG IMAGE_ARG 26 ENV IMAGE=${IMAGE_ARG} 27 28 # common util tools 29 RUN apt-get update && apt-get install -y --no-install-recommends \ 30 build-essential \ 31 ca-certificates \ 32 curl \ 33 file \ 34 git \ 35 iproute2 \ 36 iputils-ping \ 37 jq \ 38 kmod \ 39 mercurial \ 40 openssh-client \ 41 pkg-config \ 42 procps \ 43 python3 \ 44 python3-distutils \ 45 python3-gflags \ 46 python3-pip \ 47 python3-venv \ 48 python3-yaml \ 49 rsync \ 50 unzip \ 51 wget \ 52 xz-utils \ 53 zip \ 54 zlib1g-dev \ 55 && rm -rf /var/lib/apt/lists/* \ 56 && python3 -m pip install --no-cache-dir --break-system-packages --upgrade pip setuptools wheel 57 58 # Install gcloud 59 60 ENV PATH=/google-cloud-sdk/bin:/workspace:${PATH} \ 61 CLOUDSDK_CORE_DISABLE_PROMPTS=1 62 63 ARG GCLOUD_SDK_URL=https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz 64 RUN wget -O google-cloud-sdk.tar.gz -q $GCLOUD_SDK_URL && \ 65 tar xzf google-cloud-sdk.tar.gz -C / && \ 66 rm google-cloud-sdk.tar.gz && \ 67 /google-cloud-sdk/install.sh \ 68 --disable-installation-options \ 69 --bash-completion=false \ 70 --path-update=false \ 71 --usage-reporting=false && \ 72 gcloud components install alpha beta kubectl && \ 73 gcloud info | tee /workspace/gcloud-info.txt 74 75 76 # 77 # BEGIN: DOCKER IN DOCKER SETUP 78 # 79 80 # Install Docker deps, some of these are already installed in the image but 81 # that's fine since they won't re-install and we can reuse the code below 82 # for another image someday. 83 RUN apt-get update && apt-get install -y --no-install-recommends \ 84 apt-transport-https \ 85 ca-certificates \ 86 curl \ 87 gnupg2 \ 88 software-properties-common \ 89 lsb-release && \ 90 rm -rf /var/lib/apt/lists/* 91 92 # Add the Docker apt-repository 93 RUN curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \ 94 && chmod a+r /etc/apt/keyrings/docker.gpg \ 95 && echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ 96 "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ 97 tee /etc/apt/sources.list.d/docker.list > /dev/null 98 99 # Install Docker 100 # TODO: the `sed` is a bit of a hack, look into alternatives. 101 # Why this exists: `docker service start` on debian runs a `cgroupfs_mount` method, 102 # We're already inside docker though so we can be sure these are already mounted. 103 # Trying to remount these makes for a very noisy error block in the beginning of 104 # the pod logs, so we just comment out the call to it... :shrug: 105 RUN apt-get update && \ 106 apt-get install -y --no-install-recommends docker-ce docker-buildx-plugin && \ 107 rm -rf /var/lib/apt/lists/* && \ 108 sed -i 's/cgroupfs_mount$/#cgroupfs_mount\n/' /etc/init.d/docker \ 109 && update-alternatives --set iptables /usr/sbin/iptables-legacy \ 110 && update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy 111 112 113 114 # Move Docker's storage location 115 RUN echo 'DOCKER_OPTS="${DOCKER_OPTS} --data-root=/docker-graph"' | \ 116 tee --append /etc/default/docker 117 # NOTE this should be mounted and persisted as a volume ideally (!) 118 # We will make a fallback one now just in case 119 RUN mkdir /docker-graph 120 121 # 122 # END: DOCKER IN DOCKER SETUP 123 # 124 125 126 # note the runner is also responsible for making docker in docker function if 127 # env DOCKER_IN_DOCKER_ENABLED is set and similarly responsible for generating 128 # .bazelrc files if bazel remote caching is enabled 129 COPY ["entrypoint.sh", "runner.sh", "create_bazel_cache_rcs.sh", \ 130 "/usr/local/bin/"] 131 132 # TODO(krzyzacy): Move the scenario scripts to kubekins v2 133 # The bundled scenarios are for podutil jobs, bootstrap jobs will still use 134 # scenario scripts from cloned test-infra 135 RUN mkdir /workspace/scenarios 136 COPY ["./scenarios", "/workspace/scenarios"] 137 138 RUN git clone https://github.com/kubernetes/test-infra /workspace/test-infra 139 140 ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]