Signed-off-by: Uwe Hermann <uh@uleenucks.de>
This commit is contained in:
@@ -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
|
||||
+24
-20
@@ -16,24 +16,34 @@ dcleanup(){
|
||||
"${DOCKER}" rmi $("${DOCKER}" images --filter dangling=true -q 2>/dev/null) 2>/dev/null
|
||||
}
|
||||
|
||||
build_and_push_kaniko(){
|
||||
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
|
||||
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 "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() {
|
||||
@@ -48,7 +58,7 @@ dofile() {
|
||||
fi
|
||||
|
||||
{
|
||||
$SCRIPT build_and_push_kaniko "${base}" "${suite}" "${build_dir}"
|
||||
$SCRIPT build_and_push "${base}" "${suite}" "${build_dir}"
|
||||
} || {
|
||||
# add to errors
|
||||
echo "${base}:${suite}" >> "$ERRORS"
|
||||
@@ -57,23 +67,17 @@ dofile() {
|
||||
echo
|
||||
}
|
||||
|
||||
prescript(){
|
||||
cd "${DOCKERFILESPATH}"
|
||||
rm -f errors
|
||||
git pull
|
||||
}
|
||||
|
||||
main(){
|
||||
# get the dockerfiles
|
||||
IFS=$'\n'
|
||||
files=( $(find . -iname '*Dockerfile' | sed 's|./||' | sort) )
|
||||
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[@]}"
|
||||
|
||||
if [[ ! -f $ERRORS ]]; then
|
||||
if [[ ! -f "$ERRORS" ]]; then
|
||||
echo "No errors, hooray!"
|
||||
else
|
||||
echo "[ERROR] Some images did not build correctly, see below." >&2
|
||||
@@ -83,7 +87,7 @@ main(){
|
||||
}
|
||||
|
||||
run(){
|
||||
args=$@
|
||||
args=$*
|
||||
f=$1
|
||||
|
||||
if [[ "$f" == "" ]]; then
|
||||
@@ -93,6 +97,6 @@ run(){
|
||||
fi
|
||||
}
|
||||
|
||||
run "$@"
|
||||
#prescript
|
||||
run $@
|
||||
dcleanup
|
||||
|
||||
Reference in New Issue
Block a user