From dc3a21dc3a8499e1da51b3402dd5f1824d26841b Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Fri, 4 Feb 2022 16:48:35 +0530 Subject: [PATCH] Use smaller windows base image (#12) --- docker/Dockerfile.windows.amd64.1809 | 11 ++++++++++- docker/Dockerfile.windows.amd64.1909 | 12 +++++++++++- plugin/plugin.go | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile.windows.amd64.1809 b/docker/Dockerfile.windows.amd64.1809 index 8cdbafa..e5ffec0 100644 --- a/docker/Dockerfile.windows.amd64.1809 +++ b/docker/Dockerfile.windows.amd64.1809 @@ -1,12 +1,21 @@ # escape=` -FROM mcr.microsoft.com/windows/servercore:1809 +FROM mcr.microsoft.com/windows/servercore:1809 as base SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] USER ContainerAdministrator ENV GODEBUG=netdns=go RUN mkdir /bin RUN Invoke-WebRequest https://releases.jfrog.io/artifactory/jfrog-cli/v2/2.10.0/jfrog-cli-windows-amd64/jfrog.exe -OutFile C:/bin/jfrog.exe + +FROM mcr.microsoft.com/powershell:nanoserver-1809 +COPY --from=base /bin /bin + ADD release/windows/amd64/plugin C:/bin/drone-artifactory.exe +# 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';"] ENTRYPOINT [ "C:\\bin\\drone-artifactory.exe" ] \ No newline at end of file diff --git a/docker/Dockerfile.windows.amd64.1909 b/docker/Dockerfile.windows.amd64.1909 index 0ae848a..b4f205f 100644 --- a/docker/Dockerfile.windows.amd64.1909 +++ b/docker/Dockerfile.windows.amd64.1909 @@ -1,11 +1,21 @@ # escape=` -FROM mcr.microsoft.com/windows/servercore:1909 + +FROM mcr.microsoft.com/windows/servercore:1909 as base SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] USER ContainerAdministrator ENV GODEBUG=netdns=go RUN mkdir /bin RUN Invoke-WebRequest https://releases.jfrog.io/artifactory/jfrog-cli/v2/2.10.0/jfrog-cli-windows-amd64/jfrog.exe -OutFile C:/bin/jfrog.exe + +FROM mcr.microsoft.com/powershell:nanoserver-1909 +COPY --from=base /bin /bin + ADD release/windows/amd64/plugin C:/bin/drone-artifactory.exe +# 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';"] ENTRYPOINT [ "C:\\bin\\drone-artifactory.exe" ] \ No newline at end of file diff --git a/plugin/plugin.go b/plugin/plugin.go index 3af583f..3f6e049 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -80,7 +80,7 @@ func Exec(ctx context.Context, args Args) error { func getShell() (string, string) { if runtime.GOOS == "windows" { - return "powershell", "-Command" + return "pwsh", "-Command" } return "sh", "-c"