0
votes

I have a Windowserver in a docker file where i'm trying to enable compression on server side, The docker file looks like this

# escape=`
FROM  mcr.microsoft.com/windows/servercore:1803
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
LABEL cmbappname="cmbimage"
WORKDIR /inetpub/wwwroot
RUN Install-WindowsFeature -name Web-Server -IncludeManagementTools ;`
    Install-WindowsFeature -name Web-Dyn-Compression ;`
    Install-WindowsFeature -name Web-Basic-Auth ;`
    Install-WindowsFeature -name Web-Windows-Auth ;`
    Install-WindowsFeature -name Web-Net-Ext45 ;`
    Install-WindowsFeature -name Web-ISAPI-Ext ;`
    Install-WindowsFeature -name Web-WebSockets; `  
    Install-WindowsFeature -name Web-ISAPI-Filter ;`
    Install-WindowsFeature -name Web-WHC ;`
    Install-WindowsFeature NET-Framework-45-ASPNET ; `
    Install-WindowsFeature Web-Asp-Net45 ;`
    Install-WindowsFeature -Name Web-Mgmt-Service ;`
    Install-WindowsFeature -name Web-Mgmt-Tools ;`
    Install-WindowsFeature -name Web-Mgmt-Compat ;`
    Install-WindowsFeature -name Web-Scripting-Tools ;`
    Dism /online /enable-feature /featurename:IIS-ManagementService /all ;`
    dism /online /enable-feature /featurename:IIS-HttpCompressionDynamic ;`
    dism /online /enable-feature /all /featurename:iis-webserver /NoRestart ;
RUN New-item c:\test -ItemType "directory" 
RUN Invoke-WebRequest https://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi -OutFile C:\test\rewrite_amd64.msi
RUN Start-Process 'c:\test\rewrite_amd64.msi' '/qn' -PassThru | Wait-Process;
RUN dism /online /enable-feature /all /featurename:iis-webserver /NoRestart 
RUN Invoke-WebRequest https://download.microsoft.com/download/6/1/C/61CC0718-ED0E-4351-BC54-46495EBF5CC3/iiscompression_amd64.msi -OutFile C:\test\compression.msi
RUN Start-Process 'c:\test\compression.msi' '/qn' -PassThru | Wait-Process;
RUN & $env:windir\system32\inetsrv\appcmd set config -section:urlCompression /doDynamicCompression:true

RUN & $env:windir\system32\inetsrv\appcmd set config /section:system.webServer/httpCompression  "/scheme[name=gzip].staticCompressionLevel:9"

EXPOSE 443 
EXPOSE 80 

The docker file builds just fine till

RUN & $env:windir\system32\inetsrv\appcmd set config /section:system.webServer/httpCompression  "/scheme[name=gzip].staticCompressionLevel:9"

on this line powershell throws an exception

ERROR ( message:Malformed collection indexer; format is [@position,name='value',name2='value2',...]. The @position specifier is optional, and be '@start', '@end', or '@N' where N is a numeric index into the collection. ) The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; & $env:windir\system32\inetsrv\appcmd set config /section:system.webServer/httpCompression "/scheme[name=gzip].staticCompressionLevel:9"' returned a non-zero code: 1

1

1 Answers

0
votes

You can try to add quote around gzip like this:

appcmd set config /section:system.webServer/httpCompression  "/scheme[name='gzip'].staticCompressionLevel:9"