From 9baf25d1ea32c90e51ef36fb5f0373449a57a779 Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 24 Sep 2019 19:10:14 -0700 Subject: [PATCH 1/3] Remove Windows 1803 support Drone only supports Windows 1809 and up. --- docker/Dockerfile.windows.1803 | 20 -------------------- docker/manifest.tmpl | 6 ------ 2 files changed, 26 deletions(-) delete mode 100644 docker/Dockerfile.windows.1803 diff --git a/docker/Dockerfile.windows.1803 b/docker/Dockerfile.windows.1803 deleted file mode 100644 index cbd58a7..0000000 --- a/docker/Dockerfile.windows.1803 +++ /dev/null @@ -1,20 +0,0 @@ -# escape=` - -FROM mcr.microsoft.com/windows/servercore:1803 AS git -SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] - -RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` - Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; ` - Expand-Archive git.zip -DestinationPath C:\git; - -FROM mcr.microsoft.com/powershell:nanoserver-1803 -COPY --from=git /git /git - -ADD windows/* /bin/ - -# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137 -USER ContainerAdministrator -RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell" - -SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -CMD [ "pwsh", "C:\\bin\\clone.ps1" ] diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl index 04a45a9..ed4576a 100644 --- a/docker/manifest.tmpl +++ b/docker/manifest.tmpl @@ -29,12 +29,6 @@ manifests: variant: v6 architecture: arm os: linux - - - image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1803-amd64 - platform: - architecture: amd64 - os: windows - version: 1803 - image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64 platform: From 66bd2d8131f8c81aee41747e2489539d14d17fc3 Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 24 Sep 2019 19:12:09 -0700 Subject: [PATCH 2/3] Update Windows dockerfiles Use a environment variable for the git version to use. This will make it easier when updating versions. Also remove build container since a version of nanoserver with powershell is being used. --- docker/Dockerfile.windows.1809 | 29 +++++++++++++++++------------ docker/Dockerfile.windows.1903 | 29 +++++++++++++++++------------ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/docker/Dockerfile.windows.1809 b/docker/Dockerfile.windows.1809 index 936400d..0c49d61 100644 --- a/docker/Dockerfile.windows.1809 +++ b/docker/Dockerfile.windows.1809 @@ -1,20 +1,25 @@ # escape=` +FROM mcr.microsoft.com/powershell:nanoserver-1809 +USER ContainerAdministrator -FROM mcr.microsoft.com/windows/servercore:1809 AS git -SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] +ENV PATH="$PATH;C:\git\cmd" ` + GIT_VERSION="2.23.0.1" -RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` - Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; ` - Expand-Archive git.zip -DestinationPath C:\git; +SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -FROM mcr.microsoft.com/powershell:nanoserver-1809 -COPY --from=git /git /git +RUN $major, $minor, $patch, $build = $env:GIT_VERSION.split('.'); ` + if ($build -ne '1') { ` + $exePath = ('MinGit-{0}.{1}.{2}.{3}-busybox-64-bit.zip' -f $major, $minor, $patch, $build); ` + } ` + else { ` + $exePath = ('MinGit-{0}.{1}.{2}-busybox-64-bit.zip' -f $major, $minor, $patch); ` + } ` + $url = ('https://github.com/git-for-windows/git/releases/download/v{0}.{1}.{2}.windows.{3}/{4}' -f $major, $minor, $patch, $build, $exePath); ` + Invoke-WebRequest -UseBasicParsing $url -OutFile git.zip; ` + Expand-Archive git.zip -DestinationPath C:\git; ` + Remove-Item git.zip; ` + git --version; ADD windows/* /bin/ -# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137 -USER ContainerAdministrator -RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell" - -SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] CMD [ "pwsh", "C:\\bin\\clone.ps1" ] diff --git a/docker/Dockerfile.windows.1903 b/docker/Dockerfile.windows.1903 index 71982da..8360a3a 100644 --- a/docker/Dockerfile.windows.1903 +++ b/docker/Dockerfile.windows.1903 @@ -1,20 +1,25 @@ # escape=` +FROM mcr.microsoft.com/powershell:nanoserver-1903 +USER ContainerAdministrator -FROM mcr.microsoft.com/windows/servercore:1903 AS git -SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] +ENV PATH="$PATH;C:\git\cmd" ` + GIT_VERSION="2.23.0.1" -RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; ` - Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; ` - Expand-Archive git.zip -DestinationPath C:\git; +SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] -FROM mcr.microsoft.com/powershell:nanoserver-1903 -COPY --from=git /git /git +RUN $major, $minor, $patch, $build = $env:GIT_VERSION.split('.'); ` + if ($build -ne '1') { ` + $exePath = ('MinGit-{0}.{1}.{2}.{3}-busybox-64-bit.zip' -f $major, $minor, $patch, $build); ` + } ` + else { ` + $exePath = ('MinGit-{0}.{1}.{2}-busybox-64-bit.zip' -f $major, $minor, $patch); ` + } ` + $url = ('https://github.com/git-for-windows/git/releases/download/v{0}.{1}.{2}.windows.{3}/{4}' -f $major, $minor, $patch, $build, $exePath); ` + Invoke-WebRequest -UseBasicParsing $url -OutFile git.zip; ` + Expand-Archive git.zip -DestinationPath C:\git; ` + Remove-Item git.zip; ` + git --version; ADD windows/* /bin/ -# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137 -USER ContainerAdministrator -RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell" - -SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] CMD [ "pwsh", "C:\\bin\\clone.ps1" ] From 58c7fe4be4ef8664fc5ad5a373feeeb800f8279b Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 24 Sep 2019 19:18:41 -0700 Subject: [PATCH 3/3] Remove hack for adding git to path on Windows --- windows/clone.ps1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/windows/clone.ps1 b/windows/clone.ps1 index 4be8cc4..fd43a86 100644 --- a/windows/clone.ps1 +++ b/windows/clone.ps1 @@ -1,9 +1,5 @@ $ErrorActionPreference = 'Stop'; -# HACK: no clue how to set the PATH inside the Dockerfile, -# so am setting it here instead. This is not idea. -$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin' - # if the workspace is set we should make sure # it is the current working directory.