【Azure Developer】已发布好的.NET Core项目文件如何打包为Docker镜像文件

在博文(【Azure App Service For Container】创建ASP.NET Core Blazor项目并打包为Linux镜像发布到Azure应用服务)中我们通过VS 2019可以为项目添加Dockerfile并自动生成Docker Image文件。但是如果不借助于VS2019我们如何来操作呢?

 

解决步骤 准备Dockerfile

进入项目文件夹中,创建Dockerfile并COPY以下内容:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. #Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed. #For more information, please see https://aka.ms/containercompat FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build ENV ASPNETCORE_URLS=http://+:8000 
WORKDIR /app EXPOSE 8000 EXPOSE 5000 COPY . /app/ ENTRYPOINT ["dotnet", "MyLife.Blazor.Server.dll"]

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwwjjg.html