Skip to content

Commit

Permalink
Pass labels from image to manifest
Browse files Browse the repository at this point in the history
Also fix a duplication bug which will reduce the amount of push builds we're doing
  • Loading branch information
WyriHaximus committed Jan 14, 2025
1 parent 3e838ee commit 3d17f4b
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions utils/create-manifest-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,33 @@

foreach (array_unique(
array_map(
static fn (string $tag): string => str_replace(
array_map(
static fn (string $tag): string => '-' . $tag,
$archs
static fn (string $tag): string => trim(
str_replace(
array_map(
static fn (string $tag): string => '-' . $tag,
$archs
),
'',
$tag,
),
'',
$tag,
),
file('tags-to-push.list')
)
) as $image) {
$dockerFilename = 'docker-file-' . md5($argv[1] . "/" . trim($image));
file_put_contents($dockerFilename, 'FROM ' . $argv[1] . "/" . trim($image) . '-${TARGETARCH}');
$labels = [];
$imageName = $argv[1] . "/" . trim($image);

file_put_contents('./command.sh', "\ndocker buildx build -f " . $dockerFilename . " --platform=linux/" . implode(",linux/", $archs) . " -t \"" . $argv[1] . "/" . trim($image) . "\" --push .\n", \FILE_APPEND);
$jsonString = null;
exec('docker inspect --format=\'{{json .Config.Labels}}\' ' . $imageName . '-' . $archs[0], $jsonString);
$json = json_decode($jsonString[0], true);
foreach ($json as $labelKey => $labelValue) {
$labels[] = '--label ' . $labelKey . '="' . $labelValue . '"';
}

$dockerFilename = 'docker-file-' . md5($imageName);
file_put_contents($dockerFilename, 'FROM ' . $imageName . '-${TARGETARCH}');

file_put_contents('./command.sh', "\ndocker buildx build " . implode(' ', $labels) . " -f " . $dockerFilename . " --platform=linux/" . implode(",linux/", $archs) . " -t \"" . $imageName . "\" --push .\n", \FILE_APPEND);
}

file_put_contents(
Expand Down

0 comments on commit 3d17f4b

Please sign in to comment.