From 7e73e594bd167ca05d3b3c77a07d3009f95b9ab8 Mon Sep 17 00:00:00 2001 From: Hubbe Date: Fri, 8 Nov 2024 10:03:20 +0200 Subject: [PATCH] Use --manifest, --platform, and --jobs to parallelize --- build | 62 +++++++++++++++++++++++++---------------------------------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/build b/build index 1f209d4..03650ef 100755 --- a/build +++ b/build @@ -76,38 +76,28 @@ for component in "${COMPONENTS[@]}"; do latest="$BASE/wubloader-$component:latest" specific="$BASE/wubloader-$component:$TAG" if [ -n "$MULTIPLATFORM" ]; then - echo "Creating multi-arch manifest" - "$BUILD_CMD" manifest create "wubloader-$component" - # no way to build multi-arch in parallel, so just build amd64 first and then arm64. - # caching should work with both, so that'll make things less painful at least. - "$BUILD_CMD" build \ - -f "$component/Dockerfile" \ - -t "$latest" \ - -t "$specific" \ - --manifest "wubloader-$component" \ - --arch amd64 \ - "${CACHE_ARGS[@]}" \ - . + echo "Creating multi-arch manifests" + "$BUILD_CMD" manifest create "$specific" + "$BUILD_CMD" manifest create "$latest" + # buscribe doesn't (yet?) build under arm64 due to pulling in libc-bin, skip arm64 for it if [ "$component" != "buscribe" ]; then "$BUILD_CMD" build \ - -f "$component/Dockerfile" \ - -t "$latest" \ - -t "$specific" \ - --manifest "wubloader-$component" \ - --arch arm64 \ + -f "$component/Dockerfile' \ + --manifest "$specific" \ + --manifest "$latest" \ + --jobs 2 \ + --platform=linux/amd64,linux/arm64 \ + "${CACHE_ARGS[@]}" \ + . + else + "$BUILD_CMD" build \ + -f "$component/Dockerfile' \ + --manifest "$specific" \ + --manifest "$latest" \ + --platform=linux/amd64 \ "${CACHE_ARGS[@]}" \ . - fi - echo "Built image wubloader-$component:$TAG" - # manifest pushes are buildah-specific. docker buildx multiplatform builds have different syntax... - if [ -n "$PUSH" ]; then - echo "Pushing tag $specific" - "$BUILD_CMD" manifest push --all "$specific" - fi - if [ "$PUSH" == "latest" ]; then - echo "Pushing tag $latest" - "$BUILD_CMD" manifest push --all "$latest" fi else "$BUILD_CMD" build \ @@ -117,14 +107,14 @@ for component in "${COMPONENTS[@]}"; do --manifest "wubloader-$component" \ "${CACHE_ARGS[@]}" \ . - echo "Built image wubloader-$component:$TAG" - if [ -n "$PUSH" ]; then - echo "Pushing tag $specific" - "$BUILD_CMD" push "$specific" - fi - if [ "$PUSH" == "latest" ]; then - echo "Pushing tag $latest" - "$BUILD_CMD" push "$latest" - fi + fi + echo "Built image wubloader-$component:$TAG" + if [ -n "$PUSH" ]; then + echo "Pushing tag $specific" + "$BUILD_CMD" push "$specific" + fi + if [ "$PUSH" == "latest" ]; then + echo "Pushing tag $latest" + "$BUILD_CMD" push "$latest" fi done