Skip to content

Commit

Permalink
Merge pull request #259 from WyriHaximusNet/pass-labels-from-image-to…
Browse files Browse the repository at this point in the history
…-manifest

Pass labels from image to manifest
  • Loading branch information
WyriHaximus authored Jan 14, 2025
2 parents 3e838ee + 3d17f4b commit c529081
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 c529081

Please sign in to comment.