docker-archive / communitytools-image2docker-win

305 stars 78 forks source link

Handle IIS WebSites with multiple Web Applications #24

Open sixeyed opened 7 years ago

sixeyed commented 7 years ago

Currently this breaks in Generate_IIS, but we need to extend Discover_IIS and the artifact JSON to allow for multiple Web Apps under one Web Site. Sample applicationHost.config:

<sites>
            <site name="Default Web Site" id="1">
                <application path="/">
                    <virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
                </application>
                <application path="/WebApplication1" applicationPool="DefaultAppPool">
                    <virtualDirectory path="/" physicalPath="C:\scm\github\sixeyed\IisConsoleLog\WebApplication1" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:80:" />
                </bindings>
            </site>
...

The solution also needs to support the same setup in Metabase.xml configuration.

We should support three scenarios:

1 - allow a specific web app to be extracted from a VM. E.g. in the above sample we have the website called Default Web Site which contains an app called WebApplication1. Users should be able to extract just that app into the Dockerfile with -Artifact IIS -ArtifactParam 'Default Web Site/WebApplication1'

2 - If a website but not a web app is specified as a parameter, extract all the web apps in the website into the Dockerfile, e.g. -Artifact IIS -ArtifactParam 'Default Web Site'

3 - if no artifact parameter specified, preserve the existing IIS setup - bringing all websites and all web apps into the Dockerfile, e.g. -Artifact IIS

sixeyed commented 7 years ago

Fixed in 1.8

BrazilPowered commented 7 years ago

Hey sixeyed, I'm using version 1.8.2, and I get a crash each time I try to run this: ConvertTo-Dockerfile -RemotePath \\IP.add.res.s1\c$ -Verbose -OutputPath C:\i2d2\folder -Artifact IIS -ArtifactParam "Default Web Site/Application_NAME"

It yields this error:

Generate_IIS : You cannot call a method on a null-valued expression.
At C:\WINDOWS\system32\docker\communitytools-image2docker-win\Functions\Private\GenerateDockerfile.ps1:37 char:23
+ ... ockerfile = & "Generate_$Artifact" -MountPath $MountPath -ManifestPat ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Generate_IIS], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull,Generate_IIS

The same goes for using -Local instead of -RemotePath. I also get the same error if I don't include any -ArtifactParam for both -Local and -RemotePath

The only thing that seems to work with either is changing the -ArtifactParam to iis-env, in which case I only get the IIS services, and none of the websites. Though I do see the application appear in the resulting applicationHost.config.

Can you help me figure out if I'm missing something, or if this might be a similar issue? It might be important to note that the application I'm looking at resides under the Default Web Site under "Default Web Site/Application_NAME"?

dvsergeenko commented 7 years ago

Hey! I'am using 1.8.2 too and experiencing the same issue then trying to convert .vhd image with multuple IIS sites on it. Generate_IIS : You cannot call a method on a null-valued expression. At C:\Program Files\WindowsPowerShell\Modules\Image2Docker\1.8.2\Functions\Private\GenerateDockerfile.ps1:37 char:23

bspann commented 7 years ago

I am getting the same thing using 1.8.5 by running the following command: ConvertTo-Dockerfile -ImagePath "D:\Virtual Machines\Windows Server 2008\Virtual Hard Disks\Windows Server 2008.vhdx" -Artifact IIS -ArtifactParam 'Default Web Site/JSSK' -OutputPath C:\website\IIS -Verbose

Not only am I getting the error but the website directory it copies out is not the correct one in the VM.

beigewell commented 6 years ago

I also have this issue has anyone found a workaround? I have tried looking into the Generate IIS ps1 but nothing seems out of the ordinary. I have multiple sites this doesnt work with when trying local or vhdx source.

beigewell commented 6 years ago

fix usage of ProcessDirectory #62 has worked for most of my sites