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 ceb1cab
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .build/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ spec:
cd e2e
source ./tools.sh
perpare
docker run --rm --net=host -v $(pwd):/workspace -v ~/.docker/config.json:/root/.docker/config.json --privileged --entrypoint /workspace/test.sh build-harbor.alauda.cn/devops/buildkit:v0.13.1-alpine-3c2de0bd
docker run --rm --net=host -v $(pwd):/workspace -v ~/.docker/:/root/.docker/ --privileged --entrypoint /workspace/test.sh build-harbor.alauda.cn/devops/buildkit:v0.13.1-alpine-3c2de0bd
workspaces:
- name: source
workspace: source
Expand Down
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 .



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


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 ceb1cab

Please sign in to comment.