mirror of
https://code.thetadev.de/actions/kaniko.git
synced 2026-04-28 20:01:42 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e528090290 | ||
|
|
71f14860d8 | ||
|
|
4be1d51afa | ||
|
|
dbb8da86cf | ||
|
|
67a2ae32b0 | ||
|
|
4866315586 | ||
|
|
79ca97c0a2 |
10
Dockerfile
10
Dockerfile
@@ -1,4 +1,4 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.21.0-debug
|
FROM gcr.io/kaniko-project/executor:v1.24.0-debug
|
||||||
|
|
||||||
SHELL ["/busybox/sh", "-c"]
|
SHELL ["/busybox/sh", "-c"]
|
||||||
|
|
||||||
@@ -6,12 +6,12 @@ SHELL ["/busybox/sh", "-c"]
|
|||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
case "$(arch)" in \
|
case "$(arch)" in \
|
||||||
'x86_64') \
|
'x86_64') \
|
||||||
url='https://github.com/google/go-containerregistry/releases/download/v0.19.0/go-containerregistry_Linux_x86_64.tar.gz'; \
|
url='https://github.com/google/go-containerregistry/releases/download/v0.20.6/go-containerregistry_Linux_x86_64.tar.gz'; \
|
||||||
sha256='daa629648e1d1d10fc8bde5e6ce4176cbc0cd48a32211b28c3fd806e0fa5f29b'; \
|
sha256='c1d593d01551f2c9a3df5ca0a0be4385a839bd9b86d4a76e18d7b17d16559127'; \
|
||||||
;; \
|
;; \
|
||||||
'aarch64') \
|
'aarch64') \
|
||||||
url='https://github.com/google/go-containerregistry/releases/download/v0.19.0/go-containerregistry_Linux_arm64.tar.gz'; \
|
url='https://github.com/google/go-containerregistry/releases/download/v0.20.6/go-containerregistry_Linux_arm64.tar.gz'; \
|
||||||
sha256='d439957c1a9d6bc0870be921e25753a7fa67bf2b2691b77ce48a6fc25bc719a0'; \
|
sha256='fc0515857bc38e4ddd2d37a5ab03fb5959449c7b2d4ad759bcc1174ac0cad91b'; \
|
||||||
;; \
|
;; \
|
||||||
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
|
*) echo >&2 "error: unsupported architecture '$arch' (likely packaging update needed)"; exit 1 ;; \
|
||||||
esac; \
|
esac; \
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -15,7 +15,7 @@ Viscreanu.
|
|||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- name: Build docker image
|
- name: Build docker image
|
||||||
uses: https://code.thetadev.de/ThetaDev/action-kaniko@v1
|
uses: https://code.thetadev.de/actions/kaniko@v1
|
||||||
with:
|
with:
|
||||||
image: thetadev256/test-actions-helloworld2
|
image: thetadev256/test-actions-helloworld2
|
||||||
username: thetadev256
|
username: thetadev256
|
||||||
@@ -218,3 +218,16 @@ Example: `thetadev256/test-actions-helloworld2:main`
|
|||||||
Full reference to the built image with registry and tag.
|
Full reference to the built image with registry and tag.
|
||||||
|
|
||||||
Example: `thetadev256/test-actions-helloworld2:main`
|
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)
|
||||||
|
|||||||
@@ -96,7 +96,27 @@ if [ -n "$INPUT_PLATFORMS" ]; then
|
|||||||
DESTINATION="--no-push --tarPath /kaniko/build/${platformFn}.tar --destination $IMAGE"
|
DESTINATION="--no-push --tarPath /kaniko/build/${platformFn}.tar --destination $IMAGE"
|
||||||
DIGEST="--image-name-tag-with-digest-file=/kaniko/build/${platformFn}_image-tag-digest"
|
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")"
|
echo "✅ $platform image built: $(head -n 1 "/kaniko/build/${platformFn}_image-tag-digest")"
|
||||||
done
|
done
|
||||||
@@ -113,14 +133,13 @@ if [ -n "$INPUT_PLATFORMS" ]; then
|
|||||||
DIGESTS="$DIGESTS -m $digest"
|
DIGESTS="$DIGESTS -m $digest"
|
||||||
done
|
done
|
||||||
|
|
||||||
TAGS="-t $IMAGE"
|
manifest_cmd="crane index append -t $IMAGE $DIGESTS"
|
||||||
if [ -n "$IMAGE_LATEST" ]; then
|
|
||||||
TAGS="$TAGS -t $IMAGE_LATEST"
|
|
||||||
fi
|
|
||||||
|
|
||||||
manifest_cmd="crane index append $TAGS $DIGESTS"
|
|
||||||
echo "Building manifest: $manifest_cmd"
|
echo "Building manifest: $manifest_cmd"
|
||||||
IMAGE_TAG_DIGEST=$(eval "$manifest_cmd")
|
IMAGE_TAG_DIGEST=$(eval "$manifest_cmd")
|
||||||
|
|
||||||
|
if [ -n "$IMAGE_LATEST" ]; then
|
||||||
|
crane tag "$IMAGE" latest
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# Build and push image for the default platform
|
# Build and push image for the default platform
|
||||||
echo "⚒️ Building image $IMAGE"
|
echo "⚒️ Building image $IMAGE"
|
||||||
|
|||||||
Reference in New Issue
Block a user