We have a ASP.Net MVC app and which works fine when we run even locally in debug mode from Visual Studio. We have 4 Class library projects and one web api project. Following is my docker file:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.sln .
COPY xxxxx/*.csproj ./xxxxx/
COPY yyyyyy/*.csproj ./yyyyy/
# copy everything else and build app
COPY xxxxx/ ./xxxxx/
COPY yyyyy/ ./yyyyy/
RUN nuget restore
WORKDIR /app/GetThree
RUN msbuild /p:Configuration=Release
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8 AS runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /app/xxxxx/. ./
Once I build the docker file, everything compiles properly and build is successful also (all Nuget packages are restored) and I am able to create the container as well. But unfortunately whenever I try to browse to my web-app (I got the IP address of the container as this is windows base) but unfortunately I get HTTP 500 internal server error immediately. I have made sure that the HTTPERROR section is set for detailed error message.
As soon as I navigate to the ip address I get this 500 error and unfortunately not much is availble in the logs (Application or System) which will help me as to what the issue could be. Any help?
Following is the command I use to build and run the container:
docker build -f .\GetThree\Dockerfile -t threecms/cmsdocker:1.0
docker run --name threecms --rm -it -p 8100:80 threecms/cmsdocker:1.0
To browse the site I get the IP Address (using docker exec threecms ipconfig) and I browse it using: http://ipadress:8100
UPDATE 1:-
I created one more image from above image using following dockerfile ( urlrewrite is the URLREWRITE module install script)
FROM threecms/cmsdocker:1.0
WORKDIR C:/
Copy urlrewrite.ps1/ .
RUN "Powershell ./urlrewrite.ps1"
RUN Install-WindowsFeature Web-Mgmt-Service; \
New-ItemProperty -Path HKLM:\software\microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force; \
Set-Service -Name wmsvc -StartupType automatic;
URL REWRITE PS1 script:
New-Item c:/msi -ItemType Directory
Invoke-WebRequest 'http://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi' -OutFile c:/msi/WebPlatformInstaller_amd64_en-US.msi
Start-Process 'c:/msi/WebPlatformInstaller_amd64_en-US.msi' '/qn' -PassThru | Wait-Process
cd 'C:/Program Files/Microsoft/Web Platform Installer'; .\WebpiCmd.exe /Install /Products:'UrlRewrite2,ARRv3_0' /AcceptEULA /Log:c:/msi/WebpiCmd.log
Then I ran the container using following command:-
docker run --name threecms2 -d cmswindfeature/cmswinfeature:3.0
And now whenever I got to my application from browser it gives me the actual error msg which is:
Access to the path 'C:\inetpub\wwwroot\App_Data\TEMP\PluginCache\umbraco-plugins.373F7AAE388A.hash' is denied.
UPDATE:-2 RESOLVED
So to Resolve above error I ran the following Powershell script (To add required Permissions) and Boom I was able to access my site and its working now:-
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
$acl = Get-ACL "C:\inetpub\wwwroot"
$acl.AddAccessRule($accessRule)
Set-ACL -Path "C:\inetpub\wwwroot" -ACLObject $acl