AWS Codebuild "Unknown runtime version named '3.1' of dotnet. This build image has the following versions: 2.2"
AWS Codebuild "Unknown runtime version named '3.1' of dotnet. This build image has the following versions: 2.2"
我正在使用 codepipeline 行来构建和部署 - 从 github 拉取并部署到 fargate 容器 - 在 codebuild 中构建 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>
从亚马逊转移到亚马逊 Linux 2 x86_64 standard:3.0 Linux 2 x86_64 standard:1.0 解决了这个问题!
根据评论。
此问题是由于使用旧运行时映像版本 Amazon Linux 2 x86_64 standard:1.0
引起的,该版本 不支持 dotnet 3.1。如 AWS docs 中所列,仅以下版本支持 dotnet 3.1:
亚马逊 Linux 2 x86_64 standard:3.0
亚马逊 Linux 2 AArch64 standard:2.0
Ubuntu standard:4.0
Ubuntu standard:5.0
因此,解决方案是升级镜像版本到Amazon Linux 2 x86_64 standard:3.0
。
我正在使用 codepipeline 行来构建和部署 - 从 github 拉取并部署到 fargate 容器 - 在 codebuild 中构建 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>
从亚马逊转移到亚马逊 Linux 2 x86_64 standard:3.0 Linux 2 x86_64 standard:1.0 解决了这个问题!
根据评论。
此问题是由于使用旧运行时映像版本 Amazon Linux 2 x86_64 standard:1.0
引起的,该版本 不支持 dotnet 3.1。如 AWS docs 中所列,仅以下版本支持 dotnet 3.1:
亚马逊 Linux 2 x86_64 standard:3.0
亚马逊 Linux 2 AArch64 standard:2.0
Ubuntu standard:4.0
Ubuntu standard:5.0
因此,解决方案是升级镜像版本到Amazon Linux 2 x86_64 standard:3.0
。