diff --git a/container-compose b/container-compose index 1a3cb83..656d2b3 100755 --- a/container-compose +++ b/container-compose @@ -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") diff --git a/testtag.sh b/testtag.sh new file mode 100755 index 0000000..ceced6b --- /dev/null +++ b/testtag.sh @@ -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"