diff --git a/src/azurelinux/3.0/net11.0/source-build-test/amd64/Dockerfile b/src/azurelinux/3.0/net11.0/source-build-test/amd64/Dockerfile deleted file mode 100644 index f9a4825fa..000000000 --- a/src/azurelinux/3.0/net11.0/source-build-test/amd64/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:10.0-preview-azurelinux3.0-amd64 AS installer - -# Install dependencies for building pyicu wheel from source (dependency of scancode-toolkit) -RUN tdnf update -y \ - && tdnf install -y \ - binutils \ - gcc-c++ \ - glibc-devel \ - icu-devel \ - kernel-headers \ - python3-devel \ - && tdnf clean all - -# Include scancode -# Install instructions: https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html#installation-as-a-library-via-pip -# See latest release at https://github.com/nexB/scancode-toolkit/releases -RUN SCANCODE_VERSION="32.4.1" \ - && python3 -m venv /venv \ - && source /venv/bin/activate \ - && pip install scancode-toolkit==$SCANCODE_VERSION \ - && pip install click==8.2.2 - - -FROM mcr.microsoft.com/dotnet/sdk:10.0-preview-azurelinux3.0-amd64 - -COPY --from=installer /venv /venv - -# Install necessary dependencies -RUN tdnf update -y \ - && tdnf install -y \ - libgomp \ - shadow-utils \ - util-linux \ - && tdnf clean all - -# Setup a script which executes scancode in the virtual environment -COPY ./run-scancode.sh /usr/local/bin/scancode -RUN chmod +x /usr/local/bin/scancode diff --git a/src/azurelinux/3.0/net11.0/source-build-test/amd64/run-scancode.sh b/src/azurelinux/3.0/net11.0/source-build-test/amd64/run-scancode.sh deleted file mode 100644 index 06163330c..000000000 --- a/src/azurelinux/3.0/net11.0/source-build-test/amd64/run-scancode.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -euo pipefail -source /venv/bin/activate -scancode "$@" -deactivate \ No newline at end of file diff --git a/src/azurelinux/3.0/net10.0/source-build-test/amd64/Dockerfile b/src/azurelinux/3.0/net8.0/source-build-test/amd64/Dockerfile similarity index 86% rename from src/azurelinux/3.0/net10.0/source-build-test/amd64/Dockerfile rename to src/azurelinux/3.0/net8.0/source-build-test/amd64/Dockerfile index a2ae7baec..464d7f947 100644 --- a/src/azurelinux/3.0/net10.0/source-build-test/amd64/Dockerfile +++ b/src/azurelinux/3.0/net8.0/source-build-test/amd64/Dockerfile @@ -1,4 +1,5 @@ -FROM mcr.microsoft.com/dotnet/sdk:10.0-azurelinux3.0-amd64 AS installer +ARG DOTNET_VERSION +FROM mcr.microsoft.com/dotnet/sdk:$DOTNET_VERSION-azurelinux3.0-amd64 AS installer # Install dependencies for building pyicu wheel from source (dependency of scancode-toolkit) RUN tdnf update -y \ @@ -21,7 +22,7 @@ RUN SCANCODE_VERSION="32.4.1" \ && pip install click==8.2.2 -FROM mcr.microsoft.com/dotnet/sdk:10.0-azurelinux3.0-amd64 +FROM mcr.microsoft.com/dotnet/sdk:$DOTNET_VERSION-azurelinux3.0-amd64 COPY --from=installer /venv /venv diff --git a/src/azurelinux/3.0/net10.0/source-build-test/amd64/run-scancode.sh b/src/azurelinux/3.0/net8.0/source-build-test/amd64/run-scancode.sh similarity index 100% rename from src/azurelinux/3.0/net10.0/source-build-test/amd64/run-scancode.sh rename to src/azurelinux/3.0/net8.0/source-build-test/amd64/run-scancode.sh diff --git a/src/azurelinux/manifest.json b/src/azurelinux/manifest.json index fd183bf80..edac0f7a7 100644 --- a/src/azurelinux/manifest.json +++ b/src/azurelinux/manifest.json @@ -1337,11 +1337,11 @@ "platforms": [ { "architecture": "amd64", - "dockerfile": "src/azurelinux/3.0/net10.0/source-build-test/amd64", + "dockerfile": "src/azurelinux/3.0/net11.0/build/amd64", "os": "linux", "osVersion": "azurelinux3.0", "tags": { - "azurelinux-3.0-net10.0-source-build-test-amd64": {} + "azurelinux-3.0-net11.0-build-amd64": {} } } ] @@ -1350,11 +1350,46 @@ "platforms": [ { "architecture": "amd64", - "dockerfile": "src/azurelinux/3.0/net11.0/build/amd64", + "dockerfile": "src/azurelinux/3.0/net8.0/source-build-test/amd64", "os": "linux", "osVersion": "azurelinux3.0", "tags": { - "azurelinux-3.0-net11.0-build-amd64": {} + "azurelinux-3.0-net8.0-source-build-test-amd64": {} + }, + "buildArgs": { + "DOTNET_VERSION": "8.0" + } + } + ] + }, + { + "platforms": [ + { + "architecture": "amd64", + "dockerfile": "src/azurelinux/3.0/net8.0/source-build-test/amd64", + "os": "linux", + "osVersion": "azurelinux3.0", + "tags": { + "azurelinux-3.0-9.0-source-build-test-amd64": {} + }, + "buildArgs": { + "DOTNET_VERSION": "9.0" + } + } + ] + }, + { + "platforms": [ + { + "architecture": "amd64", + "dockerfile": "src/azurelinux/3.0/net8.0/source-build-test/amd64", + "os": "linux", + "osVersion": "azurelinux3.0", + "tags": { + "azurelinux-3.0-net10.0-source-build-test-amd64": {} + }, + "buildArgs": { + "DOTNET_VERSION": "10.0" } } ] @@ -1363,11 +1398,15 @@ "platforms": [ { "architecture": "amd64", - "dockerfile": "src/azurelinux/3.0/net11.0/source-build-test/amd64", + "dockerfile": "src/azurelinux/3.0/net8.0/source-build-test/amd64", "os": "linux", "osVersion": "azurelinux3.0", "tags": { "azurelinux-3.0-net11.0-source-build-test-amd64": {} + }, + "buildArgs": { + // TODO: Update to 11 once images are available + "DOTNET_VERSION": "10.0" } } ] diff --git a/tests/Microsoft.DotNet.BuildTools.Prereqs.Docker.Tests/ManifestTests.cs b/tests/Microsoft.DotNet.BuildTools.Prereqs.Docker.Tests/ManifestTests.cs index 2e54bbb9c..77dfeb6b7 100644 --- a/tests/Microsoft.DotNet.BuildTools.Prereqs.Docker.Tests/ManifestTests.cs +++ b/tests/Microsoft.DotNet.BuildTools.Prereqs.Docker.Tests/ManifestTests.cs @@ -39,13 +39,14 @@ public void ValidateFolderStructure() } else { - var matchingPlatforms = platforms.Where(p => GetDockerfilePath(p) == dockerfilePath); + var matchingPlatforms = platforms.Where(p => GetDockerfilePath(p) == dockerfilePath).ToList(); if (matchingPlatforms.Count() > 1) { - if (dockerfilePath.EndsWith(arch)) + var distinctArchs = matchingPlatforms.Select(p => GetArchitecture(p)).Distinct(); + if (distinctArchs.Count() > 1 && dockerfilePath.EndsWith(arch)) { invalidDockerfilePaths.Add( - $"Dockerfile path '{dockerfilePath}' should not end with '{arch}' because it is built for multiple platforms."); + $"Dockerfile path '{dockerfilePath}' should not end with '{arch}' because it is built for multiple platforms with different architectures."); } } else if (!dockerfilePath.EndsWith(arch)) @@ -78,6 +79,14 @@ public void ValidateTags() return; } + // Skip validation if this dockerfile is shared across multiple platforms + // as there is no easy way to validate the tag structure from the Dockerfile path. + var matchingPlatforms = platforms.Where(p => GetDockerfilePath(p) == dockerfilePath); + if (matchingPlatforms.Count() > 1) + { + return; + } + string expectedTag = dockerfilePath; string dockerfileQualifier = string.Empty; if (!dockerfilePath.EndsWith(arch) && !IsCrossDockerfile(dockerfilePath)) @@ -107,11 +116,15 @@ public void ValidateTags() private void EnumerateManifests(Action action) { var manifestFiles = Directory.GetFiles(Config.SrcDirectory, "manifest.json", SearchOption.AllDirectories); + var jsonOptions = new JsonDocumentOptions + { + CommentHandling = JsonCommentHandling.Skip, + }; foreach (var manifestFile in manifestFiles) { OutputHelper.WriteLine($"Processing manifest file: {manifestFile}"); - var manifestJson = JsonDocument.Parse(File.ReadAllText(manifestFile)).RootElement; + var manifestJson = JsonDocument.Parse(File.ReadAllText(manifestFile), jsonOptions).RootElement; var platforms = manifestJson.GetProperty("repos") .EnumerateArray() .SelectMany(repo => repo.GetProperty("images").EnumerateArray()) @@ -128,7 +141,7 @@ private void EnumerateManifests(Action (platform.GetProperty("dockerfile").GetString() ?? string.Empty).TrimEnd('/'); + private static string GetDockerfilePath(JsonElement platform) => (platform.GetProperty("dockerfile").GetString() ?? string.Empty).TrimEnd('/'); - private bool IsCrossDockerfile(string dockerfilePath) => dockerfilePath.Contains("/cross/"); + private static bool IsCrossDockerfile(string dockerfilePath) => dockerfilePath.Contains("/cross/"); }