容器化具有附加类库项目的 ASP.NET

问题描述 投票:0回答:0

我想容器化一个 ASP.NET 应用程序。整个解决方案路径看起来像这样

我试过这样写Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /app

# Copy the project files
COPY . ./MyApp

# Copy the Infrastructure project file
COPY ../Infrastructure/ ./Infrastructure/

# Restore NuGet packages
RUN dotnet restore

# Build the solution
RUN dotnet build

# Publish the ASP.NET app to a directory called "app"
RUN dotnet publish -c Release -o /app

# Build the final image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /app
COPY --from=build-env /app .

# Expose the port and start the app
EXPOSE 80
ENTRYPOINT ["dotnet", "MyApp.dll"]

但是我得到一个错误

我做错了什么以及如何修复我的 Dockerfile?我是否必须将它移动到 ParentDirectory 或其他东西?我可以保留我当前的解决方案结构并仍然容器化这个应用程序吗?

asp.net docker dockerfile class-library
© www.soinside.com 2019 - 2024. All rights reserved.