* MOD: again finalize tests stage
build_and_push / build_and_push (push) Has been cancelled

Signed-off-by: Uwe Hermann <uh@uleenucks.de>
This commit is contained in:
2024-01-20 13:33:32 +01:00
parent b69c6d2c25
commit 4d79420110
2 changed files with 71 additions and 66 deletions
+7 -6
View File
@@ -6,12 +6,13 @@ on:
jobs:
lint:
name: build_and_push
runs-on: ubuntu-latest
runs-on: docker-stable
defaults:
run:
shell: sh
steps:
- uses: actions/checkout@v4
- name: Install docker
run: curl -fsSL https://get.docker.com | sh
- name: Install parallel
run: apt install parallel -y
- name: build_and_push
- name: Login to docker
run: docker login -u uleenucks -p ${{ secrets.CI_TOKEN }}
- name: Build docker container
run: ./build-all.sh
+63 -59
View File
@@ -16,83 +16,87 @@ dcleanup(){
"${DOCKER}" rmi $("${DOCKER}" images --filter dangling=true -q 2>/dev/null) 2>/dev/null
}
build_and_push_kaniko(){
base=$1
suite=$2
build_dir=$3
build_and_push(){
base=$1
suite=$2
build_dir=$3
echo "Building ${REPO_URL}/${base}:${suite} for context ${build_dir}"
docker run \
-v "$(pwd)/config.json:/kaniko/.docker/config.json:ro" \
-v "$(pwd)/${build_dir}:/workspace" \
gcr.io/kaniko-project/executor:debug \
--destination "${REPO_URL}/${base}:${suite}" --force \
--context dir:///workspace/ \
|| return 1
echo "Building ${REPO_URL}/${base}:${suite} for context ${build_dir}"
docker build --rm --force-rm -t "${REPO_URL}/${base}:${suite}" "${build_dir}" || return 1
# on successful build, push the image
echo " --- "
echo "Successfully built and pushed ${base}:${suite} with context ${build_dir}"
echo " --- "
# on successful build, push the image
echo " --- "
echo "Successfully built ${base}:${suite} with context ${build_dir}"
echo " --- "
# try push a few times because notary server sometimes returns 401 for
# absolutely no reason
n=0
until [ $n -ge 5 ]; do
docker push --disable-content-trust=false "${REPO_URL}/${base}:${suite}" && break
echo "Try #$n failed... sleeping for 15 seconds"
n=$((n+1))
sleep 15
done
# also push the tag latest for "stable" (chrome), "tools" (wireguard) or "3.5" tags for zookeeper
if [[ "$suite" == "stable" ]] || [[ "$suite" == "3.6" ]] || [[ "$suite" == "tools" ]]; then
docker tag "${REPO_URL}/${base}:${suite}" "${REPO_URL}/${base}:latest"
docker push --disable-content-trust=false "${REPO_URL}/${base}:latest"
fi
}
dofile() {
f=$1
image=${f%Dockerfile}
base=${image%%\/*}
build_dir=$(dirname "$f")
suite=${build_dir##*\/}
f=$1
image=${f%Dockerfile}
base=${image%%\/*}
build_dir=$(dirname "$f")
suite=${build_dir##*\/}
if [[ -z "$suite" ]] || [[ "$suite" == "$base" ]]; then
suite=latest
fi
if [[ -z "$suite" ]] || [[ "$suite" == "$base" ]]; then
suite=latest
fi
{
$SCRIPT build_and_push_kaniko "${base}" "${suite}" "${build_dir}"
} || {
# add to errors
echo "${base}:${suite}" >> "$ERRORS"
}
echo
echo
{
$SCRIPT build_and_push "${base}" "${suite}" "${build_dir}"
} || {
# add to errors
echo "${base}:${suite}" >> "$ERRORS"
}
prescript(){
cd "${DOCKERFILESPATH}"
rm -f errors
git pull
echo
echo
}
main(){
# get the dockerfiles
IFS=$'\n'
files=( $(find . -iname '*Dockerfile' | sed 's|./||' | sort) )
unset IFS
# get the dockerfiles
IFS=$'\n'
mapfile -t files < <(find -L . -iname '*Dockerfile' | sed 's|./||' | sort)
unset IFS
# build all dockerfiles
echo "Running in parallel with ${JOBS} jobs."
parallel --tag --verbose --ungroup -j"${JOBS}" "$SCRIPT" dofile "{1}" ::: "${files[@]}"
# build all dockerfiles
echo "Running in parallel with ${JOBS} jobs."
parallel --tag --verbose --ungroup -j"${JOBS}" "$SCRIPT" dofile "{1}" ::: "${files[@]}"
if [[ ! -f $ERRORS ]]; then
echo "No errors, hooray!"
else
echo "[ERROR] Some images did not build correctly, see below." >&2
echo "These images failed: $(cat "$ERRORS")" >&2
exit 1
fi
if [[ ! -f "$ERRORS" ]]; then
echo "No errors, hooray!"
else
echo "[ERROR] Some images did not build correctly, see below." >&2
echo "These images failed: $(cat "$ERRORS")" >&2
exit 1
fi
}
run(){
args=$@
f=$1
args=$*
f=$1
if [[ "$f" == "" ]]; then
main "$args"
else
$args
fi
if [[ "$f" == "" ]]; then
main "$args"
else
$args
fi
}
run "$@"
#prescript
run $@
dcleanup