Skip to content

Commit

Permalink
feat: add buildkit image test.
Browse files Browse the repository at this point in the history
  • Loading branch information
kycheng committed Apr 8, 2024
1 parent c2f2dc9 commit 4186f64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG FROM_IMAGE=registry.alauda.cn:60080

FROM ${FROM_IMAGE}/ops/alpine:3
COPY test.txt .
COPY Dockerfile .



27 changes: 14 additions & 13 deletions e2e/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eu
#!/bin/sh
set -exu


: ${BUILDCTL=buildctl}
Expand All @@ -14,30 +14,31 @@ set -eu
# * log
tmp=$(mktemp -d /tmp/buildctl-daemonless.XXXXXX)
trap "kill \$(cat $tmp/pid) || true; wait \$(cat $tmp/pid) || true; rm -rf $tmp" EXIT
source ./tools.sh


# Define an array of Docker registry addresses
REGISTRIES=("registry.alauda.cn:60080" "registry.alauda.cn:60070" "build-harbor.alauda.cn" "localhost" "localhost:4443")
source /workspace/tools.sh

# 启动 buildkitd 守护进程
echo "start buildkitd..."
startBuildkitd
waitForBuildkitd

formats=(oci docker)
format=oci
random_index=$((RANDOM % 2))
if [ $random_index -eq 0 ];
then
format=docker
fi

# Loop through all Docker registry addresses, login, build, and push the image
for REGISTRY in "${REGISTRIES[@]}"
do
for REGISTRY in "registry.alauda.cn:60080" "registry.alauda.cn:60070" "build-harbor.alauda.cn" "localhost" "localhost:4443"; do
echo "Building and pull the image from $REGISTRY ..."
buildctl build \
--frontend=dockerfile.v0 \
--opt label:format=${formats[$random_index]} \
--opt label:format=${format} \
--opt label:format_id=${random_index} \
--local context=. --local dockerfile=. --opt build-arg:FROM_IMAGE=$REGISTRY \
--output type=${formats[$random_index]},dest=./image.tar
--opt build-arg:FROM_IMAGE=$REGISTRY \
--local context=/workspace --local dockerfile=/workspace \
--output type=${format},dest=./image.tar

rm -f image.tar
done

Expand Down

0 comments on commit 4186f64

Please sign in to comment.