Prechádzať zdrojové kódy

Merge pull request #39807 from thaJeztah/ci_busybox

hack/ci/windows.ps1: build busybox from local Dockerfile
Sebastiaan van Stijn 5 rokov pred
rodič
commit
ff99a93b81
3 zmenil súbory, kde vykonal 58 pridanie a 17 odobranie
  1. 30 0
      contrib/busybox/Dockerfile
  2. 21 0
      contrib/busybox/LICENSE
  3. 7 17
      hack/ci/windows.ps1

+ 30 - 0
contrib/busybox/Dockerfile

@@ -0,0 +1,30 @@
+# Source: https://frippery.org/busybox/
+# This Dockerfile builds a (32-bit) busybox images which is suitable for
+# running many of the integration-cli tests for Docker against a Windows
+# daemon. It will not run on nanoserver as that is 64-bit only.
+#
+# Based on https://github.com/jhowardmsft/busybox
+# John Howard (IRC jhowardmsft, Email john.howard@microsoft.com)
+#
+# To build: docker build -t busybox .
+# To publish: Needs someone with publishing rights
+ARG WINDOWS_BASE_IMAGE=mcr.microsoft.com/windows/servercore
+ARG WINDOWS_BASE_IMAGE_TAG=ltsc2019
+ARG BUSYBOX_VERSION=FRP-3329-gcf0fa4d13
+
+# Checksum taken from https://frippery.org/files/busybox/SHA256SUM
+ARG BUSYBOX_SHA256SUM=bfaeb88638e580fc522a68e69072e305308f9747563e51fa085eec60ca39a5ae
+
+FROM ${WINDOWS_BASE_IMAGE}:${WINDOWS_BASE_IMAGE_TAG}
+RUN mkdir C:\tmp && mkdir C:\bin
+ARG BUSYBOX_VERSION
+ARG BUSYBOX_SHA256SUM
+ADD https://frippery.org/files/busybox/busybox-w32-${BUSYBOX_VERSION}.exe /bin/busybox.exe
+RUN powershell \
+    if ((Get-FileHash -Path /bin/busybox.exe -Algorithm SHA256).Hash -ne $Env:BUSYBOX_SHA256SUM) { \
+        Throw \"Checksum validation failed\" \
+    }
+
+RUN setx /M PATH "C:\bin;%PATH%"
+RUN powershell busybox.exe --list ^|%{$nul = cmd /c mklink C:\bin\$_.exe busybox.exe}
+CMD ["sh"]

+ 21 - 0
contrib/busybox/LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 John Howard (Microsoft)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 7 - 17
hack/ci/windows.ps1

@@ -161,7 +161,7 @@ Function Nuke-Everything {
             }
 
             $allImages  = $(docker images --format "{{.Repository}}#{{.ID}}")
-            $toRemove   = ($allImages | Select-String -NotMatch "servercore","nanoserver","docker")
+            $toRemove   = ($allImages | Select-String -NotMatch "servercore","nanoserver","docker","busybox")
             $imageCount = ($toRemove | Measure-Object -line).Lines
 
             if ($imageCount -gt 0) {
@@ -827,23 +827,13 @@ Try {
     # Add the Windows busybox image. Needed for WCOW integration tests
     if (($null -eq $env:LCOW_MODE) -and ($null -eq $env:LCOW_BASIC_MODE)) {
         if ($null -eq $env:SKIP_INTEGRATION_TESTS) {
+            Write-Host -ForegroundColor Green "INFO: Building busybox"
             $ErrorActionPreference = "SilentlyContinue"
-            # Build it regardless while switching between nanoserver and windowsservercore
-            #$bbCount = $(& "$env:TEMP\binary\docker-$COMMITHASH" "-H=$($DASHH_CUT)" images | Select-String "busybox" | Measure-Object -line).Lines
-            #$ErrorActionPreference = "Stop"
-            #if (-not($LastExitCode -eq 0)) {
-            #    Throw "ERROR: Could not determine if busybox image is present"
-            #}
-            #if ($bbCount -eq 0) {
-                Write-Host -ForegroundColor Green "INFO: Building busybox"
-                $ErrorActionPreference = "SilentlyContinue"
-                $(& "$env:TEMP\binary\docker-$COMMITHASH" "-H=$($DASHH_CUT)" build -t busybox https://raw.githubusercontent.com/moby/busybox/v1.1/Dockerfile | Out-Host)
-                $ErrorActionPreference = "Stop"
-                if (-not($LastExitCode -eq 0)) {
-                    Throw "ERROR: Failed to build busybox image"
-                }
-            #}
-
+            $(& "$env:TEMP\binary\docker-$COMMITHASH" "-H=$($DASHH_CUT)" build  -t busybox --build-arg WINDOWS_BASE_IMAGE --build-arg WINDOWS_BASE_IMAGE_TAG "$env:SOURCES_DRIVE`:\$env:SOURCES_SUBDIR\src\github.com\docker\docker\contrib\busybox\" | Out-Host)
+            $ErrorActionPreference = "Stop"
+            if (-not($LastExitCode -eq 0)) {
+                Throw "ERROR: Failed to build busybox image"
+            }
 
             Write-Host -ForegroundColor Green "INFO: Docker images of the daemon under test"
             Write-Host