test tagging

This commit is contained in:
Shihaam Abdul Rahman 2023-10-08 00:00:59 +05:00
parent dc5833730c
commit cd10376a3e
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636
2 changed files with 43 additions and 3 deletions

View File

@ -146,11 +146,35 @@ build(){
if [ -z "$context" ]; then
context="."
fi
$engine buildx build --platform $platform -t $new_image_tag -f $context/$dockerfile $context
$engine buildx build --platform $platform -t $new_image_tag -f $context/$dockerfile $context --load
done
}
#push(){
#}
push(){
services=$(yq e '.services | keys | .[]' "$file")
for service in $services; do
platform=$(yq e ".services.$service.platform" "$file")
image=$(yq e ".services.$service.image" "$file")
build=$(yq e ".services.$service.build" "$file")
context=$(yq e ".services.$service.build.context" "$file")
dockerfile=$(yq e ".services.$service.build.dockerfile" "$file")
# Replace '/' and ':' with '-' in the platform string to make it suitable for a tag
platform_tag=$(echo "$platform" | tr '/:' '-')
# Append platform information to the image tag
new_image_tag="${image}-${platform_tag}"
# If dockerfile is null or empty, set it to "Dockerfile"
if [ -z "$dockerfile" ]; then
dockerfile="Dockerfile"
fi
if [ -z "$context" ]; then
context="."
fi
$engine push $new_image_tag
done
$engine manifest create $image
}
pull(){
services=$(yq e '.services | keys | .[]' "$file")

16
testtag.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
image="nginx:latest"
platforms=("amd64" "arm64")
engine="docker"
# Start the command string
cmd="$engine manifest create $image"
# Append each platform-specific image to the command string
for platform in "${platforms[@]}"; do
cmd+=" $image-$platform"
done
# Output the complete command string
echo "$cmd"