1
votes

We are using MsDeploy for deploying our site on IIS. When we publish we get three files, viz.

  • MySite.deploy.cmd,
  • MySite.SetParameters.xml
  • MySite.zip.

And we run a command like;

MySite.cmd /Y /M:https://IpOfMachine/MsDeploy.axd

to deploy on the server.

Now we want to move it to docker, with docker file something like this -

FROM microsoft/iis

RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot*

WORKDIR C:/DeploymentFiles

COPY DeploymentPackage/ .

RUN cmd MySite.cmd /Y /M:https://IpOfDockerInstance/MsDeploy.axd

But the MsDeploy thing is not working and giving 404 error. I think I need to add WebDepoly to get this working, but how to do it in Docker? Any suggestions, please. I am a novice to Docker

1

1 Answers

1
votes

It could be difficult to get started with docker, if one's is not through well with the basics. I spent some time in reading out more on it and finally come up with the following Docker file that worked for me. I have tired to document the script inline with a couple of references that helped me.

FROM microsoft/iis

#Keep the artifacts related for image in the same folder from where docker is running

RUN cmd mkdir C:/DeploymentFiles
WORKDIR C:/DeploymentFiles

# Copy and install msdeploy service
COPY WebDeploy_amd64_en-US.msi .
RUN msiexec /i WebDeploy_amd64_en-US.msi AGREETOLICENSE=yes ADDLOCAL=ALL /qn
RUN powershell Start-service MsDepSvc;

#Remove default iis site's contents
RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*


# Resolving 403 issue. Ref - https://github.com/microsoft/iis-docker/issues/5

#Adding a user so i can connect trough IIS Manager
RUN NET USER testing "Password01!" /ADD
RUN NET LOCALGROUP "Administrators" "testing" /add

#Grant Permissions
RUN icacls "C:\inetpub\wwwroot\*" /grant everyone:(OI)(CI)F /T

#Install neccassary features
RUN powershell Install-WindowsFeature Web-Mgmt-Service
RUN powershell Install-WindowsFeature Web-Windows-Auth
RUN powershell Install-WindowsFeature NET-Framework-45-ASPNET
RUN powershell Install-WindowsFeature Web-Asp-Net45
RUN powershell Install-WindowsFeature NET-WCF-HTTP-Activation45

#Start Service and make it autorun
RUN net start wmsvc
RUN sc config WMSVC start= auto
RUN powershell -NoProfile -Command \

Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1

# Copy deployment packages and related files to container to "C:/DeploymentFiles"
COPY DeployPackage/ .
# The Deploy_App.bat file contains the command to deploy using msdeploy
COPY Deploy_App.bat .

RUN C:/DeploymentFiles/Deploy_App.bat

# Resolve the ACL issues during deployment. Ref - https://fluentbytes.com/how-to-fix-error-this-access-control-list-is-not-in-canonical-form-and-therefore-cannot-be-modified-error-count-1/
COPY aclFix.ps1 .
RUN powershell.exe -executionpolicy bypass .\aclFix.ps1

RUN C:/DeploymentFiles/Deploy_App.bat

EXPOSE 80