Use --manifest, --platform, and --jobs to parallelize

HubbeKing-multiplatform-builds
Hubbe 2 weeks ago committed by GitHub
parent 4749520db3
commit 7e73e594bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

62
build

@ -76,38 +76,28 @@ for component in "${COMPONENTS[@]}"; do
latest="$BASE/wubloader-$component:latest" latest="$BASE/wubloader-$component:latest"
specific="$BASE/wubloader-$component:$TAG" specific="$BASE/wubloader-$component:$TAG"
if [ -n "$MULTIPLATFORM" ]; then if [ -n "$MULTIPLATFORM" ]; then
echo "Creating multi-arch manifest" echo "Creating multi-arch manifests"
"$BUILD_CMD" manifest create "wubloader-$component" "$BUILD_CMD" manifest create "$specific"
# no way to build multi-arch in parallel, so just build amd64 first and then arm64. "$BUILD_CMD" manifest create "$latest"
# 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[@]}" \
.
# buscribe doesn't (yet?) build under arm64 due to pulling in libc-bin, skip arm64 for it # buscribe doesn't (yet?) build under arm64 due to pulling in libc-bin, skip arm64 for it
if [ "$component" != "buscribe" ]; then if [ "$component" != "buscribe" ]; then
"$BUILD_CMD" build \ "$BUILD_CMD" build \
-f "$component/Dockerfile" \ -f "$component/Dockerfile' \
-t "$latest" \ --manifest "$specific" \
-t "$specific" \ --manifest "$latest" \
--manifest "wubloader-$component" \ --jobs 2 \
--arch arm64 \ --platform=linux/amd64,linux/arm64 \
"${CACHE_ARGS[@]}" \
.
else
"$BUILD_CMD" build \
-f "$component/Dockerfile' \
--manifest "$specific" \
--manifest "$latest" \
--platform=linux/amd64 \
"${CACHE_ARGS[@]}" \ "${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 fi
else else
"$BUILD_CMD" build \ "$BUILD_CMD" build \
@ -117,14 +107,14 @@ for component in "${COMPONENTS[@]}"; do
--manifest "wubloader-$component" \ --manifest "wubloader-$component" \
"${CACHE_ARGS[@]}" \ "${CACHE_ARGS[@]}" \
. .
echo "Built image wubloader-$component:$TAG" fi
if [ -n "$PUSH" ]; then echo "Built image wubloader-$component:$TAG"
echo "Pushing tag $specific" if [ -n "$PUSH" ]; then
"$BUILD_CMD" push "$specific" echo "Pushing tag $specific"
fi "$BUILD_CMD" push "$specific"
if [ "$PUSH" == "latest" ]; then fi
echo "Pushing tag $latest" if [ "$PUSH" == "latest" ]; then
"$BUILD_CMD" push "$latest" echo "Pushing tag $latest"
fi "$BUILD_CMD" push "$latest"
fi fi
done done

Loading…
Cancel
Save