Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ImageBuilder, file pusher, and yaml updater all into the same namespace #1594

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
**/out
**/.vscode
**/.vs
.Microsoft.DotNet.ImageBuilder
.ImageBuilder
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/releases/new-windows-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Windows version: <version>
## Tasks

1. - [ ] Well before the Windows release date, contact DDFUN to schedule the provisioning of an Azure scale set for the new Windows version.
2. - [ ] If necessary, update [`PlatformInfo.cs`](https://github.com/dotnet/docker-tools/blob/main/src/Microsoft.DotNet.ImageBuilder/src/ViewModel/PlatformInfo.cs) to generate the correct README display name from the version specified in the manifest. This is usually not needed unless Windows changes its naming scheme, since the code is version-independent.
2. - [ ] If necessary, update [`PlatformInfo.cs`](https://github.com/dotnet/docker-tools/blob/main/src/ImageBuilder/src/ViewModel/PlatformInfo.cs) to generate the correct README display name from the version specified in the manifest. This is usually not needed unless Windows changes its naming scheme, since the code is version-independent.
3. - [ ] Add support for new Windows version in common pipeline templates:
- [ ] Add new default pool variables to [`variables/common.yml`](https://github.com/dotnet/docker-tools/blob/3ba01b2b9abc1c28cd694cbddc11f5fdd8c70e8e/eng/common/templates/variables/common.yml#L48-L59)
- [ ] Add parameter for new windows default pool in [`stages/build-test-publish-repo.yml`](https://github.com/dotnet/docker-tools/blob/3ba01b2b9abc1c28cd694cbddc11f5fdd8c70e8e/eng/common/templates/stages/build-test-publish-repo.yml#L38-L39).
Expand Down
3 changes: 1 addition & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ version: 2
updates:
- package-ecosystem: "nuget"
directories:
- "/src/Microsoft.DotNet.ImageBuilder/"
- "/eng/src/"
- "/"
schedule:
interval: "weekly"
day: "monday"
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
**/*.user

# ImageBuilder directory
.Microsoft.DotNet.ImageBuilder
.ImageBuilder

# dotnet install directory
.dotnet/
Expand Down
86 changes: 86 additions & 0 deletions Microsoft.DotNet.DockerTools.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilePusher", "src\FilePusher\FilePusher.csproj", "{100D6FD0-4B06-4BC4-8057-92664316AAC0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YamlUpdater", "src\YamlUpdater\YamlUpdater.csproj", "{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageBuilder", "src\ImageBuilder\ImageBuilder.csproj", "{D37492B0-2DD5-42C8-9811-0CA4968D4091}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageBuilder.Tests", "tests\ImageBuilder.Tests\ImageBuilder.Tests.csproj", "{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Debug|x64.ActiveCfg = Debug|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Debug|x64.Build.0 = Debug|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Debug|x86.ActiveCfg = Debug|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Debug|x86.Build.0 = Debug|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Release|Any CPU.Build.0 = Release|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Release|x64.ActiveCfg = Release|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Release|x64.Build.0 = Release|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Release|x86.ActiveCfg = Release|Any CPU
{100D6FD0-4B06-4BC4-8057-92664316AAC0}.Release|x86.Build.0 = Release|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Debug|x64.ActiveCfg = Debug|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Debug|x64.Build.0 = Debug|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Debug|x86.ActiveCfg = Debug|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Debug|x86.Build.0 = Debug|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Release|Any CPU.Build.0 = Release|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Release|x64.ActiveCfg = Release|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Release|x64.Build.0 = Release|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Release|x86.ActiveCfg = Release|Any CPU
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F}.Release|x86.Build.0 = Release|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Debug|x64.ActiveCfg = Debug|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Debug|x64.Build.0 = Debug|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Debug|x86.ActiveCfg = Debug|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Debug|x86.Build.0 = Debug|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Release|Any CPU.Build.0 = Release|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Release|x64.ActiveCfg = Release|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Release|x64.Build.0 = Release|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Release|x86.ActiveCfg = Release|Any CPU
{D37492B0-2DD5-42C8-9811-0CA4968D4091}.Release|x86.Build.0 = Release|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Debug|x64.ActiveCfg = Debug|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Debug|x64.Build.0 = Debug|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Debug|x86.ActiveCfg = Debug|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Debug|x86.Build.0 = Debug|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Release|Any CPU.Build.0 = Release|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Release|x64.ActiveCfg = Release|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Release|x64.Build.0 = Release|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Release|x86.ActiveCfg = Release|Any CPU
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{100D6FD0-4B06-4BC4-8057-92664316AAC0} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{85C918F3-E1A9-40AB-AFA2-6E0A386E4D6F} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{D37492B0-2DD5-42C8-9811-0CA4968D4091} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{A5B164DA-EC4A-4318-8764-C95DEC86E2FC} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ This is a repo to house some common tools for use in the various .NET Docker rep

A tool used to build and publish Docker images.

The Image Builder tool can be acquired via a Docker image available at [mcr.microsoft.com/dotnet-buildtools/image-builder](https://mcr.microsoft.com/v2/dotnet-buildtools/image-builder/tags/list) or built from source via the [build script](./src/Microsoft.DotNet.ImageBuilder/build.ps1).
The Image Builder tool can be acquired via a Docker image available at [mcr.microsoft.com/dotnet-buildtools/image-builder](https://mcr.microsoft.com/v2/dotnet-buildtools/image-builder/tags/list) or built from source via the [build script](./src/ImageBuilder/build.ps1).

The Image Builder tool relies on metadata which defines various information needed to build and tag Docker images. The metadata is stored in a manifest.json file ([sample](https://github.com/dotnet/dotnet-docker/blob/main/manifest.json)). The metadata schema is defined in [source](./src/Microsoft.DotNet.ImageBuilder/src/Model).
The Image Builder tool relies on metadata which defines various information needed to build and tag Docker images. The metadata is stored in a manifest.json file ([sample](https://github.com/dotnet/dotnet-docker/blob/main/manifest.json)). The metadata schema is defined in [source](./src/ImageBuilder/src/Model).

The full list of supported commands can be seen by running the tool.

Expand Down
4 changes: 2 additions & 2 deletions documentation/manifest-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The manifest file is the primary source of metadata that drives the production of all .NET Docker images. It describes various attributes of the Docker images that are to be produced by a given GitHub repo. .NET Docker's engineering system consumes this file in various ways as part of the automated build pipelines and other tools. It's intended to be product-agnostic meaning that it could be used to describe metadata for Docker image production of any product, not just .NET.

For a description of the schema, see the source location at https://github.com/dotnet/docker-tools/tree/main/src/Microsoft.DotNet.ImageBuilder/src/Models/Manifest. Alternatively, you can generate a JSON schema of the manifest by using the ImageBuilder tool:
For a description of the schema, see the source location at https://github.com/dotnet/docker-tools/tree/main/src/ImageBuilder/src/Models/Manifest. Alternatively, you can generate a JSON schema of the manifest by using the ImageBuilder tool:
```
Microsoft.DotNet.ImageBuilder.exe showManifestSchema
ImageBuilder.exe showManifestSchema
```
2 changes: 1 addition & 1 deletion eng/check-base-image-subscriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"owner": "dotnet",
"repo": "docker-tools",
"branch": "main",
"path": "src/Microsoft.DotNet.ImageBuilder/manifest.json",
"path": "src/ImageBuilder/manifest.json",
"variables": {
"UniqueId": ""
}
Expand Down
4 changes: 2 additions & 2 deletions eng/common/Invoke-ImageBuilder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Executes ImageBuilder with the specified args.
The args to pass to ImageBuilder.

.PARAMETER ReuseImageBuilderImage
Indicates that a previously built ImageBuilder image is presumed to exist locally and that
Indicates that a previously built ImageBuilder image is presumed to exist locally and that
it should be used for this execution of the script. This allows some optimization when
multiple calls are being made to this script that don't require a fresh image (i.e. the
repo contents in the image don't need to be or should not be updated with each call to
Expand Down Expand Up @@ -99,6 +99,6 @@ finally {
if ($containerCreated) {
Exec "docker container rm -f $imageBuilderContainerName"
}

popd
}
2 changes: 1 addition & 1 deletion eng/pipelines/push-common-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
vmImage: $(defaultLinuxAmd64PoolImage)
steps:
- script: >
docker build . -f ./eng/src/file-pusher/Dockerfile -t file-pusher
docker build -f ./src/FilePusher/Dockerfile -t file-pusher .
displayName: Build File Pusher
- script: >
docker run --rm file-pusher
Expand Down
6 changes: 3 additions & 3 deletions eng/pipelines/templates/variables/image-builder.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
variables:
- template: /eng/pipelines/templates/variables/build-test-publish.yml@self
- name: manifest
value: src/Microsoft.DotNet.ImageBuilder/manifest.json
value:manifest.json
- name: publishReadme
value: false
- name: manifestVariables
value: --var UniqueId=$(sourceBuildId)
- name: imageInfoVariant
value: "-imagebuilder"
- name: testScriptPath
value: ./src/Microsoft.DotNet.ImageBuilder/run-tests.ps1
value: ./tests/ImageBuilder.Tests/run-tests.ps1
- name: testResultsDirectory
value: src/Microsoft.DotNet.ImageBuilder/tests/TestResults/
value: tests/ImageBuilder.Tests/TestResults/
- name: publicGitRepoUri
value: https://github.com/dotnet/docker-tools
2 changes: 1 addition & 1 deletion eng/pipelines/update-image-builder-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
echo "##vso[task.setvariable variable=imageBuilderTag]$(cat $(Pipeline.Workspace)/image-builder/source-build-id/source-build-id.txt)"
displayName: Get Image Builder Tag
- script: >
docker build . -f ./eng/src/yaml-updater/Dockerfile -t yaml-updater
docker build -f ./src/YamlUpdater/Dockerfile -t yaml-updater .
displayName: Build YAML Updater
- script: >
docker run --rm yaml-updater
Expand Down
31 changes: 0 additions & 31 deletions eng/src/tools.sln

This file was deleted.

10 changes: 5 additions & 5 deletions ...crosoft.DotNet.ImageBuilder/manifest.json → manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"platforms": [
{
"dockerfile": "Dockerfile.linux",
"dockerfile": "src/ImageBuilder/Dockerfile.linux",
"os": "linux",
"osVersion": "azurelinux",
"tags": {
Expand All @@ -22,7 +22,7 @@
},
{
"architecture": "arm64",
"dockerfile": "Dockerfile.linux",
"dockerfile": "src/ImageBuilder/Dockerfile.linux",
"os": "linux",
"osVersion": "azurelinux",
"tags": {
Expand All @@ -36,7 +36,7 @@
"WINDOWS_BASE": "servercore:ltsc2016-amd64",
"WINDOWS_SDK": "nanoserver-1809"
},
"dockerfile": "Dockerfile.windows",
"dockerfile": "src/ImageBuilder/Dockerfile.windows",
"os": "windows",
"osVersion": "windowsservercore-ltsc2019",
"tags": {
Expand All @@ -49,7 +49,7 @@
"WINDOWS_BASE": "nanoserver:1809-amd64",
"WINDOWS_SDK": "nanoserver-1809"
},
"dockerfile": "Dockerfile.windows",
"dockerfile": "src/ImageBuilder/Dockerfile.windows",
"os": "windows",
"osVersion": "nanoserver-1809",
"tags": {
Expand All @@ -62,7 +62,7 @@
"WINDOWS_BASE": "nanoserver:ltsc2022-amd64",
"WINDOWS_SDK": "nanoserver-ltsc2022"
},
"dockerfile": "Dockerfile.windows",
"dockerfile": "src/ImageBuilder/Dockerfile.windows",
"os": "windows",
"osVersion": "nanoserver-ltsc2022",
"tags": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System.Diagnostics;

namespace FilePusher;
namespace Microsoft.DotNet.DockerTools.FilePusher;

public class AzDoSafeTraceListenerWrapper(TraceListener innerTraceListener) : TraceListener
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build-env
WORKDIR /file-pusher

# copy csproj and restore as distinct layers
COPY eng/src/file-pusher/*.csproj ./
COPY src/FilePusher/*.csproj ./
COPY NuGet.config ./
RUN dotnet restore

# copy everything else and build
COPY eng/src/file-pusher/. ./
COPY src/FilePusher/. ./
RUN dotnet publish -c Release -o out --no-restore


Expand All @@ -26,4 +26,4 @@ COPY --from=build-env /file-pusher/out ./
WORKDIR /repo
COPY . ./

ENTRYPOINT ["/file-pusher/file-pusher"]
ENTRYPOINT ["/file-pusher/FilePusher"]
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using FilePusher.Models;
using Microsoft.DotNet.DockerTools.FilePusher.Models;
using Microsoft.DotNet.VersionTools.Automation;
using Microsoft.DotNet.VersionTools.Automation.GitHubApi;
using Newtonsoft.Json;

namespace FilePusher
namespace Microsoft.DotNet.DockerTools.FilePusher
{
public class FilePusher
{
Expand Down Expand Up @@ -75,7 +75,7 @@ private async static Task AddUpdatedFile(
updatedContent = updatedContent.Replace("\r\n", "\n");
}

filePath = filePath.Replace('\\','/');
filePath = filePath.Replace('\\', '/');
string currentContent = await client.GetGitHubFileContentsAsync(filePath, branch);

if (currentContent == updatedContent)
Expand Down Expand Up @@ -191,7 +191,7 @@ public static async Task ExecuteGitOperationsWithRetryAsync(

break;
}
catch (HttpRequestException ex) when (i < (maxTries - 1))
catch (HttpRequestException ex) when (i < maxTries - 1)
{
Console.WriteLine($"Encountered exception interacting with GitHub: {ex.Message}");
Console.WriteLine($"Trying again in {retryMillisecondsDelay}ms. {maxTries - i - 1} tries left.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>FilePusher</RootNamespace>
<RootNamespace>Microsoft.DotNet.DockerTools.$(MSBuildProjectName)</RootNamespace>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using Newtonsoft.Json;

namespace FilePusher.Models
namespace Microsoft.DotNet.DockerTools.FilePusher.Models
{
public class Config
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using Newtonsoft.Json;

namespace FilePusher.Models
namespace Microsoft.DotNet.DockerTools.FilePusher.Models
{
public class GitRepo
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.CommandLine;
using System.Linq;

namespace FilePusher
namespace Microsoft.DotNet.DockerTools.FilePusher
{
public class Options
{
Expand Down
Loading