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



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

  • MySite.deploy.cmd
  • MySite.SetParameters.xml
  • 我的网站.zip.

我们运行这样的命令;

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

以在服务器上部署。

现在我们想把它移到 docker 上,使用 docker 文件像这样 -

来自微软/IIS

运行电源外壳 -NoProfile -命令删除项 -递归 C:\inetpub\wwwroot*

WORKDIR C:/DeploymentFiles

复制部署包/.

RUN cmdMySite.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:inetpubwwwroot*

# 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:inetpubwwwroot*" /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:SOFTWAREMicrosoftWebManagementServer -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

最新更新