k8s.io/kubernetes@v1.29.3/test/images/busybox/Dockerfile_windows (about) 1 # Copyright 2021 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 BASEIMAGE 16 ARG REGISTRY 17 ARG OS_VERSION 18 19 # We're using a Linux image to unpack the archive, then we're copying it over to Windows. 20 FROM --platform=linux/amd64 alpine:3.6 as prep 21 22 ENV CURL_VERSION=7.57.0 23 24 # Available busybox functions retrieved by running busybox.exe --list 25 ENV BUSYBOX_EXES="[ [[ ar arch ash awk base64 basename bash bunzip2 bzcat bzip2 cal cat chmod cksum clear cmp comm cp cpio cut date dc dd df diff dirname dos2unix dpkg-deb du echo ed egrep env expand expr factor false fgrep find fold fsync ftpget ftpput getopt grep groups gunzip gzip hd head hexdump id ipcalc kill killall less link ln logname ls lzcat lzma lzop lzopcat man md5sum mkdir mktemp mv nl od paste patch pgrep pidof pipe_progress pkill printenv printf ps pwd rev rm rmdir rpm rpm2cpio sed seq sh sha1sum sha256sum sha3sum sha512sum shred shuf sleep sort split ssl_client stat strings sum tac tail tar tee test timeout touch tr true truncate ttysize uname uncompress unexpand uniq unix2dos unlink unlzma unlzop unxz unzip usleep uudecode uuencode vi watch wc wget which whoami whois xargs xxd xz xzcat yes zcat" 26 27 ADD https://github.com/kubernetes-sigs/windows-testing/raw/master/images/busybox/busybox.exe /busybox-dir/busybox.exe 28 ADD https://skanthak.homepage.t-online.de/download/curl-$CURL_VERSION.cab /curl.cab 29 ADD https://eternallybored.org/misc/netcat/netcat-win32-1.12.zip /netcat.zip 30 ADD https://downloads.isc.org/isc/bind9/9.14.10/BIND9.14.10.x64.zip /bind.zip 31 32 # We need vcruntime140.dll in order to run dig.exe, or httpd.exe 33 ADD https://wikidll.com/download/24194/vcruntime140.zip /vcruntime140.zip 34 35 RUN apk --update add cabextract 36 37 # NOTE(claudiub): We're creating symlinks for each of the busybox binaries and after that we're copying 38 # them over to Windows. Unfortunately, docker buildx has some issues copying over Windows symlinks. 39 # "Files/" is always prepended to the symlink target. The symlinks themselves are relative paths, 40 # so, in order to make use of them, we can simply add a busybox binary to Files\busybox.exe. 41 RUN cd /busybox-dir/ && \ 42 for busybox_binary in $BUSYBOX_EXES; do ln -s busybox.exe $busybox_binary.exe; done && \ 43 mkdir Files && \ 44 cp busybox.exe Files/busybox.exe 45 46 RUN mkdir /curl-full /curl-dir && \ 47 cabextract -d /curl-full/ /curl.cab && \ 48 cp -r /curl-full/AMD64 /curl-full/CURL.LIC /curl-dir/ && \ 49 mkdir /netcat-dir && \ 50 unzip /netcat.zip -d /netcat-dir/ && \ 51 mkdir /bind-dir /dig-dir &&\ 52 unzip /bind.zip -d /bind-dir/ && \ 53 cp /bind-dir/dig.exe /bind-dir/nslookup.exe /bind-dir/*.dll /dig-dir/ && \ 54 unzip /vcruntime140.zip -d / && \ 55 mkdir /tmp-dir 56 57 58 # Windows Stage 59 FROM --platform=linux/amd64 $REGISTRY/windows-servercore-cache:1.0-linux-amd64-$OS_VERSION as servercore-helper 60 FROM --platform=linux/amd64 e2eteam/powershell-helper:6.2.7-linux-cache as ps-helper 61 FROM $BASEIMAGE 62 63 COPY --from=prep /tmp-dir /tmp 64 COPY --from=prep /busybox-dir /bin 65 COPY --from=prep /curl-dir /curl 66 COPY --from=prep /netcat-dir/nc64.exe /bin/nc.exe 67 COPY --from=prep /dig-dir /dig 68 COPY --from=prep /vcruntime140.dll /Windows/System32/ 69 70 # include nltest 71 COPY --from=servercore-helper /Windows/System32/nltest.exe /Windows/System32/nltest.exe 72 COPY --from=servercore-helper /Windows/System32/en-US/nltest.exe.mui /Windows/System32/en-US/nltest.exe.mui 73 COPY --from=servercore-helper /Windows/System32/ntdsapi.dll /Windows/System32/ntdsapi.dll 74 75 # include powershell and its Module analysis cache. 76 COPY --from=ps-helper ["/PowerShell", "/Program Files/PowerShell"] 77 78 # NOTE(claudiub): For the same reason mentioned above, we have to copy pwsh.exe to Files/pwsh.exe 79 COPY --from=ps-helper ["/PowerShell/pwsh.exe", "/Program Files/PowerShell/Files/"] 80 COPY --from=ps-helper /Users/ContainerAdministrator/AppData/Local/Microsoft/Windows/PowerShell/docker/ModuleAnalysisCache /Users/ContainerAdministrator/AppData/Local/Microsoft/Windows/PowerShell/docker/ModuleAnalysisCache 81 82 ADD hostname /bin/hostname.exe 83 84 USER ContainerAdministrator 85 86 # NOTE(claudiub): docker buildx sets the PATH env variable to a Linux-like PATH, which is not desirable. 87 ENV PATH="C:\dig\;C:\bin;C:\curl;C:\Windows\System32;C:\Windows;C:\Program Files\PowerShell;" \ 88 ProgramFiles="C:\Program Files" \ 89 # set a fixed location for the Module analysis cache 90 LOCALAPPDATA="C:\Users\ContainerAdministrator\AppData\Local" \ 91 PSModuleAnalysisCachePath="C:\Users\ContainerAdministrator\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" \ 92 # Persist %PSCORE% ENV variable for user convenience 93 PSCORE="C:\Program Files\PowerShell\pwsh.exe" 94 95 ENTRYPOINT ["cmd.exe", "/s", "/c"]