gpt4 book ai didi

asp.net - 使用MsDeploy在Docker上发布ASP.Net网站

转载 作者:行者123 更新时间:2023-12-02 19:30:02 26 4
gpt4 key购买 nike

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

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

  • 然后我们运行类似的命令;

    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。我花了一些时间阅读有关它的更多信息,最后得出了对我有用的以下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

    关于asp.net - 使用MsDeploy在Docker上发布ASP.Net网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52404779/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com