aws / aws-codebuild-docker-images

Official AWS CodeBuild repository for managed Docker images http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html
Other
1.11k stars 971 forks source link

Recent ARM image update has unintended side effects #700

Closed jwshyns closed 7 months ago

jwshyns commented 7 months ago

Describe the bug Closing this PR has resulted in existing usages of aws/codebuild/amazonlinux2-aarch64-standard:3.0 and dotnet 7 to be broken.

To Reproduce Steps to reproduce the behavior:

  1. Install dotnet 7 using this command curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel STS as demonstrated here .

Expected behavior Dotnet commands will be run using the CLI version that was explicitly installed.

Logs

[Container] 2024/02/02 00:13:03.664473 Running command curl -sSL https://dot.net/v1/dotnet-install.sh \| bash /dev/stdin --version 7.0.404
--
28 | dotnet-install: Attempting to download using primary link https://dotnetcli.azureedge.net/dotnet/Sdk/7.0.404/dotnet-sdk-7.0.404-linux-arm64.tar.gz
29 | dotnet-install: Remote file https://dotnetcli.azureedge.net/dotnet/Sdk/7.0.404/dotnet-sdk-7.0.404-linux-arm64.tar.gz size is 213920418 bytes.
30 | dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/7.0.404/dotnet-sdk-7.0.404-linux-arm64.tar.gz
31 | dotnet-install: Downloaded file size is 213920418 bytes.
32 | dotnet-install: The remote and local file sizes are equal.
33 | dotnet-install: Installed version is 7.0.404
34 | dotnet-install: Adding to current process PATH: `/root/.dotnet`. Note: This change will be visible only when sourcing script.
35 | dotnet-install: Note that the script does not resolve dependencies during installation.
36 | dotnet-install: To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the "Dependencies" section.
37 | dotnet-install: Installation finished successfully.
38 |  
39 | [Container] 2024/02/02 00:13:32.640404 Running command dotnet --version
40 | 6.0.417
41 |  
42 | [Container] 2024/02/02 00:13:40.408380 Phase complete: INSTALL State: SUCCEEDED
43 | [Container] 2024/02/02 00:13:40.408404 Phase context status code:  Message:
44 | [Container] 2024/02/02 00:13:40.453442 Entering phase PRE_BUILD
45 | [Container] 2024/02/02 00:13:40.456229 Phase complete: PRE_BUILD State: SUCCEEDED
46 | [Container] 2024/02/02 00:13:40.456244 Phase context status code:  Message:
47 | [Container] 2024/02/02 00:13:40.496370 Entering phase BUILD
48 | [Container] 2024/02/02 00:13:40.496792 Running command cdk synth
49 |  
50 | Welcome to .NET 6.0!
51 | ---------------------
52 | SDK Version: 6.0.417
53 |  
54 | Telemetry
55 | ---------
56 | The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
57 |  
58 | Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
59 |  
60 | ----------------
61 | Installed an ASP.NET Core HTTPS development certificate.
62 | To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
63 | Learn about HTTPS: https://aka.ms/dotnet-https
64 | ----------------
65 | Write your first app: https://aka.ms/dotnet-hello-world
66 | Find out what's new: https://aka.ms/dotnet-whats-new
67 | Explore documentation: https://aka.ms/dotnet-docs
68 | Report issues and find source on GitHub: https://github.com/dotnet/core
69 | Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
70 | --------------------------------------------------------------------------------------
71 | /root/.dotnet/sdk/6.0.417/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0.  Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0.

Platform (please complete the following information):

Additional context I've implemented a workaround similar to how the updates forcibly set the dotnet version (dotnet new globaljson --force --sdk-version <version here> --roll-forward feature) - I just thought I'd report the issue.

Dylan-AWS commented 7 months ago

The default version of .NET in the latest CodeBuild image is 6.0. We have released a change to ensure the default version is set properly. We have now added .NET 8 to our latest image and you no longer need to install it manually. Please use the buildspec property phases/install/runtime-versions to select your preferred version of dotnet. See documentation here: https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.phases.install

By default dotnet uses the latest version available. To set 6.0 as the default dotnet, we create a global.json file at the CodeBuild root directory(/codebuild) during the image build. The image previously did not have a global.json, and this global.json will apply to all subdirectories. To override this, a customer can select dotnet 8 in the buildspec which will create a new global.json file in the source directory(/codebuild/output/src), generate a global.json as part of their buildspec, or provide one in the source themselves. This will override the default global.json(in /codebuild) for the src directory. This allows us to have 6.0 as the default dotnet and allows customers to choose to use dotnet 8.0 if they choose to.

As mentioned the workaround will allow you to use the dotnet version you specify.