我的工作有一个用DotNet5编写的API。技术团队已经切换到所有苹果产品,现在我们正在为几个Docker文件而苦苦挣扎。我们非常肯定这与我们使用M2芯片的笔记本电脑有关,而DotNet5被弃用,只在特定的架构中可用。
原始的dockerfile命令:
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine3.12 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY Api.sln ./
COPY Source/Common/*.csproj ./Source/Common/
COPY Source/Integration/*.csproj ./Source/Integration/
COPY Source/Models/*.csproj ./Source/Models/
COPY Source/Data/*.csproj ./Source/Data/
COPY Source/BusinessLogic/*.csproj ./Source/BusinessLogic/
COPY Source/Api/*.csproj ./Source/Api/
RUN dotnet restore Source/Common/*.csproj
RUN dotnet restore Source/Integration/*.csproj
RUN dotnet restore Source/Models/*.csproj
RUN dotnet restore Source/Data/*.csproj
RUN dotnet restore Source/BusinessLogic/*.csproj
RUN dotnet restore Source/Api/*.csproj
# Copy everything else and build
WORKDIR /app/Source/Common
COPY ./Source/Common ./
RUN dotnet build -c Release -o /app/out
WORKDIR /app/Source/Integration
COPY ./Source/Integration ./
RUN dotnet build -c Release -o /app/out
WORKDIR /app/Source/Models
COPY ./Source/Models ./
RUN dotnet build -c Release -o /app/out
WORKDIR /app/Source/Data
COPY ./Source/Data ./
RUN dotnet build -c Release -o /app/out
WORKDIR /app/Source/BusinessLogic
COPY ./Source/BusinessLogic ./
RUN dotnet build -c Release -o /app/out
WORKDIR /app/Source/Api
COPY ./Source/Api ./
RUN dotnet build -c Release -o /app/out
RUN dotnet publish -c Release -o /app/out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine3.12
WORKDIR /app
COPY --from=build-env /app/out .
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV ASPNETCORE_ENVIRONMENT=Production
ARG RELEASE
ENV Sentry__Release=${RELEASE}
EXPOSE 80
ENTRYPOINT ["dotnet", "Api.dll"]
docker-compose up
在生成之前意外失败。
我们可以使用其他镜像来构建,例如mcr.microsoft.com/dotnet/sdk:6.0-alpine
和mcr.microsoft.com/dotnet/aspnet:6.0-alpine
。
但是,当启动容器时,docker返回以下错误
You must install or update .NET to run this application.
App: /app/Api.dll
Architecture: arm64
Framework: 'Microsoft.AspNetCore.App', version '5.0.0' (arm64)
.NET location: /usr/share/dotnet/
The following frameworks were found:
6.0.10 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=5.0.0&arch=arm64&rid=alpine.3.16-arm64
我已经尝试了DotNet上可用的大多数其他与Dotnet相关的图片。昨天的大部分时间都在尝试https://hub.docker.com/_/microsoft-dotnet-sdk/的AMD64和/或arm64图像的组合
另一个开发人员希望通过API并手动将所有内容迁移到DotNet6。
我在dockerfile中尝试了--roll-forward Major
命令的不同变体,但只尝试在运行时映像上实现它。是否可以在dockerfile中前滚每个单独的项目版本?
我们都是码头世界的新手,我对DotNet知之甚少。有没有办法自动迁移到DotNet 6?是否有其他坞站映像已经解决了此问题?
1条答案
按热度按时间gstyhher1#
Apple Silicon Support是在.NET6中引入的,因此您需要将您的项目/解决方案更新到该主要版本。微软有一个.NET 5 to 6 migration guide可以让你开始过渡。