使用 MsDeploy 在 Docker 上发布 ASP.Net 站点

Publish ASP.Net site on Docker using MsDeploy

我们正在使用 MsDeploy 在 IIS 上部署我们的网站。当我们发布时,我们得到三个文件,即。

我们 运行 像这样的命令;

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

在服务器上部署。

现在我们想将它移动到 docker,docker 文件是这样的 -

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

但是 MsDeploy 无法正常工作并出现 404 错误。我想我需要添加 WebDepoly 才能使其正常工作,但如何在 Docker 中添加? 任何建议,请。我是新手Docker

docker 入门可能会很困难,如果一个人的基础知识没有掌握好的话。我花了一些时间阅读更多关于它的内容,并最终提出了以下对我有用的 Docker 文件。我已经厌倦了用一些对我有帮助的参考来记录脚本内联。

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