3 Commits

Author SHA1 Message Date
ThetaDev
67a2ae32b0 fix: add support for other architectures 2024-05-31 00:56:57 +02:00
ThetaDev
4866315586 feat: add dockerfile build arguments 2024-05-31 00:23:53 +02:00
ThetaDev
79ca97c0a2 fix: tagging manifest with latest 2024-03-04 13:00:00 +01:00
2 changed files with 39 additions and 7 deletions

View File

@@ -218,3 +218,16 @@ Example: `thetadev256/test-actions-helloworld2:main`
Full reference to the built image with registry and tag.
Example: `thetadev256/test-actions-helloworld2:main`
## Dockerfile build arguments
Action-Kaniko automatically sets build arguments to allow for different dockerfile actions
depending on the OS and architecture the image is build for.
The supported arguments are:
- `TARGETPLATFORM` (example: linux/amd64)
- `TARGETOS` (example: linux)
- `TARGETARCH` (example: amd64)
- `TARGETARCH_ALT` (alternative architecture name, x86_64 for amd64, otherwise the same as TARGETARCH)
- `TARGETVARIANT` (third docker platform parameter like ARM version)

View File

@@ -96,7 +96,27 @@ if [ -n "$INPUT_PLATFORMS" ]; then
DESTINATION="--no-push --tarPath /kaniko/build/${platformFn}.tar --destination $IMAGE"
DIGEST="--image-name-tag-with-digest-file=/kaniko/build/${platformFn}_image-tag-digest"
runKaniko "${ARGS} --custom-platform=${platform} $DESTINATION $DIGEST"
targetos=$(echo "$platform" | cut -d/ -f1)
targetarch=$(echo "$platform" | cut -d/ -f2)
targetvariant=$(echo "$platform" | cut -d/ -f3)
case "$targetarch" in
'amd64') targetarchAlt="x86_64" ;;
'arm64') targetarchAlt="aarch64" ;;
'i386') targetarchAlt="i686" ;;
'386') targetarchAlt="i686" ;;
'ppc64le') targetarchAlt="powerpc64le" ;;
'arm')
case "$targetvariant" in
'v5') targetarchAlt="armv5te" ;;
'v7') targetarchAlt="armv7" ;;
*) targetarchAlt="arm" ;;
esac
;;
*) targetarchAlt="$targetarch" ;;
esac
runKaniko "${ARGS} --custom-platform=${platform} --build-arg TARGETPLATFORM='${platform}' --build-arg TARGETOS='${targetos}' --build-arg TARGETARCH='${targetarch}' --build-arg TARGETARCH_ALT='${targetarchAlt}' --build-arg TARGETVARIANT='${targetvariant}' $DESTINATION $DIGEST"
echo "$platform image built: $(head -n 1 "/kaniko/build/${platformFn}_image-tag-digest")"
done
@@ -113,14 +133,13 @@ if [ -n "$INPUT_PLATFORMS" ]; then
DIGESTS="$DIGESTS -m $digest"
done
TAGS="-t $IMAGE"
if [ -n "$IMAGE_LATEST" ]; then
TAGS="$TAGS -t $IMAGE_LATEST"
fi
manifest_cmd="crane index append $TAGS $DIGESTS"
manifest_cmd="crane index append -t $IMAGE $DIGESTS"
echo "Building manifest: $manifest_cmd"
IMAGE_TAG_DIGEST=$(eval "$manifest_cmd")
if [ -n "$IMAGE_LATEST" ]; then
crane tag "$IMAGE" latest
fi
else
# Build and push image for the default platform
echo "⚒️ Building image $IMAGE"