IIS 部署
ASP.NET Core主机捆绑包包含运行现有Web /服务器应用程序所需的一切,下载安装就完事了.
https://dotnet.microsoft.com/permalink/dotnetcore-current-windows-runtime-bundle-installer
https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=visual-studio
Docker 部署
改写dockerfile
##See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
#
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
#WORKDIR /app
#EXPOSE 80
#
#FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
#WORKDIR /src
#COPY ["WebApplication_Docker/WebApplication_Docker.csproj", "WebApplication_Docker/"]
#RUN dotnet restore "WebApplication_Docker/WebApplication_Docker.csproj"
#COPY . .
#WORKDIR "/src/WebApplication_Docker"
#RUN dotnet build "WebApplication_Docker.csproj" -c Release -o /app/build
#
#FROM build AS publish
#RUN dotnet publish "WebApplication_Docker.csproj" -c Release -o /app/publish
#
#FROM base AS final
#WORKDIR /app
#COPY --from=publish /app/publish .
#ENTRYPOINT ["dotnet", "WebApplication_Docker.dll"]
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
COPY . .
ENTRYPOINT ["dotnet", "WebApplication_Docker.dll"]
生成镜像
docker build -t mytest-mvc .
查看镜像列表
docker images
跑起来
使用docker镜像mytest-mvc:lnetcore-mvc以后台模式启动一个容器
docker run --name netcore-mvc -d -p 80:80 mytest-mvc