Skip to content

Commit 181b6fa

Browse files
Surayya Huseyn ZadaSurayya Huseyn Zada
authored andcommitted
skip publishing individual images in case of tarball and local daemon docker publishing
1 parent 7acc5e9 commit 181b6fa

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImage.Interface.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ partial class CreateNewImage
161161
[Required]
162162
public bool GenerateDigestLabel { get; set; }
163163

164+
/// <summary>
165+
/// If true, the tooling will skip the publishing step.
166+
/// </summary>
167+
public bool SkipPublishing { get; set; }
168+
164169
[Output]
165170
public string GeneratedContainerManifest { get; set; }
166171

src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImage.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,12 @@ internal async Task<bool> ExecuteAsync(CancellationToken cancellationToken)
178178
GeneratedContainerMediaType = builtImage.ManifestMediaType;
179179
GeneratedContainerNames = destinationImageReference.FullyQualifiedImageNames().Select(name => new Microsoft.Build.Utilities.TaskItem(name)).ToArray();
180180

181-
await ImagePublisher.PublishImageAsync(builtImage, sourceImageReference, destinationImageReference, Log, BuildEngine, telemetry, cancellationToken)
182-
.ConfigureAwait(false);
183-
181+
if (!SkipPublishing)
182+
{
183+
await ImagePublisher.PublishImageAsync(builtImage, sourceImageReference, destinationImageReference, Log, BuildEngine, telemetry, cancellationToken)
184+
.ConfigureAwait(false);
185+
}
186+
184187
return !Log.HasLoggedErrors;
185188
}
186189

src/Containers/packaging/build/Microsoft.NET.Build.Containers.targets

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@
274274
ContainerRuntimeIdentifier="$(ContainerRuntimeIdentifier)"
275275
ContainerUser="$(ContainerUser)"
276276
RuntimeIdentifierGraphPath="$(RuntimeIdentifierGraphPath)"
277+
SkipPublishing="$(_SkipContainerPublishing)"
277278
GenerateLabels="$(ContainerGenerateLabels)"
278279
GenerateDigestLabel="$(ContainerGenerateLabelsImageBaseDigest)"> <!-- The RID graph path is provided as a property by the SDK. -->
279280

@@ -302,6 +303,17 @@
302303
!$(ContainerArchiveOutputPath.EndsWith('\\')) and
303304
$(ContainerArchiveOutputPath.EndsWith('.tar.gz'))" />
304305

306+
<PropertyGroup>
307+
<!--We want to skip publishing individual images in case of multi-arch tarball publishing or local daemon (only docker) publishing because all images are published in one tarball.-->
308+
<!--We don't want to skip publishing individual images in case of remote registry because the individual images should be available in the registry before image index is pushed.-->
309+
<!--We don't want to skip publishing individual images in case of local daemon podman because podman loads multi-arch tarball differently - only individual image for the current platform.-->
310+
<_IsTarballPublishing Condition="'$(ContainerArchiveOutputPath)' != ''">true</_IsTarballPublishing>
311+
<_IsLocalDockerPublishing Condition="$(ContainerRegistry) == '' and ($(LocalRegistry) == '' or $(LocalRegistry) == 'Docker')">true</_IsLocalDockerPublishing>
312+
313+
<_SkipContainerPublishing>false</_SkipContainerPublishing>
314+
<_SkipContainerPublishing Condition="'$(_IsTarballPublishing)' == 'true' or '$(_IsLocalDockerPublishing)' == 'true'">true</_SkipContainerPublishing>
315+
</PropertyGroup>
316+
305317
<ItemGroup>
306318
<_rids Include="$(ContainerRuntimeIdentifiers)" Condition="'$(ContainerRuntimeIdentifiers)' != ''" />
307319
<_rids Include="$(RuntimeIdentifiers)" Condition="'$(ContainerRuntimeIdentifiers)' == '' and '$(RuntimeIdentifiers)' != ''" />
@@ -328,7 +340,8 @@
328340
_ContainerEnvironmentVariables=@(ContainerEnvironmentVariable->'%(Identity):%(Value)');
329341
ContainerUser=$(ContainerUser);
330342
ContainerGenerateLabels=$(ContainerGenerateLabels);
331-
ContainerGenerateLabelsImageBaseDigest=$(ContainerGenerateLabelsImageBaseDigest)
343+
ContainerGenerateLabelsImageBaseDigest=$(ContainerGenerateLabelsImageBaseDigest);
344+
_SkipContainerPublishing=$(_SkipContainerPublishing)
332345
"/>
333346
<_rids Remove ="$(_rids)" />
334347
</ItemGroup>

0 commit comments

Comments
 (0)