AWS Codebuild "Unknown runtime version named '3.1' of dotnet. This build image has the following v



我使用代码管线来构建和部署-从github提取并部署到fargate容器-在代码构建中构建dotnet应用程序时,我遇到了这个错误。很为难。有人知道为什么它认为我的应用程序是dotnet 2.2吗?

这是一个全新的管道


[Container] 2021/05/20 05:54:31 Waiting for agent ping
[Container] 2021/05/20 05:54:33 Waiting for DOWNLOAD_SOURCE
[Container] 2021/05/20 05:54:34 Phase is DOWNLOAD_SOURCE
[Container] 2021/05/20 05:54:34 CODEBUILD_SRC_DIR=/codebuild/output/src177986340/src
[Container] 2021/05/20 05:54:34 YAML location is /codebuild/output/src177986340/src/config/buildspec.yml
[Container] 2021/05/20 05:54:34 No commands found for phase name: install
[Container] 2021/05/20 05:54:34 Processing environment variables
[Container] 2021/05/20 05:54:35 Selecting 'dotnet' runtime version '3.1' based on manual selections...
[Container] 2021/05/20 05:54:35 Phase complete: DOWNLOAD_SOURCE State: FAILED
[Container] 2021/05/20 05:54:35 Phase context status code: YAML_FILE_ERROR Message: Unknown runtime version named '3.1' of dotnet. This build image has the following versions: 2.2

我的dockerfile指向3.1

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet",  "user-bff.dll"]

我的构建规范指向3.1

version: 0.2
phases:
install:
runtime-versions:
dotnet: 3.1
pre_build:
commands:
- cd code/
- echo Logging in to Amazon ECR
- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
- IMAGE_URI="${REPOSITORY_URI}:latest"
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build --tag "$IMAGE_URI"
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:latest
post_build:
commands:
- echo Build completed on `date`
- echo Push the latest Docker Image...
- docker push "$IMAGE_URI"
- printf '[{"name":"App","imageUri":"%s"}]' "$IMAGE_URI" > images.json
artifacts:
files: images.json

我的dotnet核心应用程序肯定是3.1

<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<RootNamespace>user_bff</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.SimpleSystemsManagement" Version="3.3.106" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.Data" Version="8.0.17" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.17" />
<PackageReference Include="Amazon.Extensions.Configuration.SystemsManager" Version="1.2.0" />
</ItemGroup>

</Project>

基于注释。

该问题是由使用旧的运行时映像版本Amazon Linux 2 x86_64 standard:1.0引起的,不支持dotnet 3.1。如AWS文档中所列,只有以下版本支持dotnet 3.1:

  • 亚马逊Linux 2 x86_64标准:3.0

  • 亚马逊Linux 2 AArch64标准:2.0

  • Ubuntu标准:4.0

  • Ubuntu标准:5.0

因此,解决方案是将映像版本升级到Amazon Linux 2 x86_64 standard:3.0

从Amazon Linux 2 x86_64标准:1.0迁移到Amazon Linux 2 x86_64标准:3.0解决了这个问题!

相关内容

  • 没有找到相关文章

最新更新