From 36b8d0931153f0224a33521f0e99fa30d7577379 Mon Sep 17 00:00:00 2001 From: Gitouche <26656-gitouche@users.noreply.framagit.org> Date: Fri, 28 Jul 2023 23:08:44 +0200 Subject: [PATCH] bette logic in build script : dont try to push to registry on failure --- podman-framadate/ci_build_images.sh | 2 +- podman-gitea/ci_build-images.sh | 22 ++++++++++++---------- podman-hedgedoc/ci_build-images.sh | 5 +++-- podman-matrix/ci_build-images.sh | 7 +++---- podman-peerjs/ci_build-images.sh | 5 +++-- podman-privatebin/ci_build_images.sh | 5 +++-- podman-seafile/ci_build-images.sh | 23 ++++++++++++----------- podman-vaultwarden/ci_build-images.sh | 5 +++-- 8 files changed, 40 insertions(+), 34 deletions(-) diff --git a/podman-framadate/ci_build_images.sh b/podman-framadate/ci_build_images.sh index d010add..1d577ad 100755 --- a/podman-framadate/ci_build_images.sh +++ b/podman-framadate/ci_build_images.sh @@ -11,6 +11,6 @@ if ! podman image exists ${framadate_image}:${framadate_version}; then podman image build -t "${framadate_image}":"${framadate_version}" --build-arg=version="${framadate_version}" container/ else echo "Image ${framadate_image}:${framadate_version} already built" -fi +fi && oci_push_to_registry ${framadate_image}:${framadate_version} diff --git a/podman-gitea/ci_build-images.sh b/podman-gitea/ci_build-images.sh index b7ce85a..c2790f7 100755 --- a/podman-gitea/ci_build-images.sh +++ b/podman-gitea/ci_build-images.sh @@ -11,18 +11,20 @@ buildfolder=/tmp/gitea-$$ if ! podman image exists ${gitea_image}:${gitea_version}; then mkdir ${buildfolder} && - git clone -b v${gitea_version} --depth=1 https://codeberg.org/forgejo/forgejo/ ${buildfolder} && { - TMPDIR=${HOME} podman image build \ - --label org.opencontainers.image.version="${gitea_version}" \ - -t ${gitea_image}:${gitea_version} -f ${buildfolder}/Dockerfile ${buildfolder} - } + git clone -b v${gitea_version} --depth=1 https://codeberg.org/forgejo/forgejo/ ${buildfolder} && { + TMPDIR=${HOME} podman image build \ + --label org.opencontainers.image.version="${gitea_version}" \ + -t ${gitea_image}:${gitea_version} \ + -f ${buildfolder}/Dockerfile ${buildfolder} || retval=false + podman image prune -a -f --filter dangling=true + podman image prune -a -f --filter intermediate=true + podman image rm -f $(podman image list -a -q -- docker.io/library/golang) + podman image rm -f $(podman image list -a -q -- docker.io/library/alpine) + } rm -rf ${buildfolder} - podman image prune -a -f --filter dangling=true - podman image prune -a -f --filter intermediate=true - podman image rm -f $(podman image list -a -q -- docker.io/library/golang) - podman image rm -f $(podman image list -a -q -- docker.io/library/alpine) + eval $retval else echo "Image ${gitea_image}:${gitea_version} already built" -fi +fi && oci_push_to_registry ${gitea_image}:${gitea_version} diff --git a/podman-hedgedoc/ci_build-images.sh b/podman-hedgedoc/ci_build-images.sh index ab03f89..31bf0f7 100755 --- a/podman-hedgedoc/ci_build-images.sh +++ b/podman-hedgedoc/ci_build-images.sh @@ -13,13 +13,14 @@ if ! podman image exists ${hedgedoc_image}:${hedgedoc_version}; then mkdir ${buildfolder} && git clone --depth=1 https://github.com/hedgedoc/container ${buildfolder}/ && { podman image build -t ${hedgedoc_image}:${hedgedoc_version} -f ${buildfolder}/alpine/Dockerfile ${buildfolder}/ - } + } || retval=false rm -rf ${buildfolder} podman image prune -a -f --filter dangling=true podman image prune -a -f --filter intermediate=true podman image rm -f $(podman image list -a -q -- docker.io/library/node) + eval $retval else echo "Image ${hedgedoc_image}:${hedgedoc_version} already built" -fi +fi && oci_push_to_registry ${hedgedoc_image}:${hedgedoc_version} diff --git a/podman-matrix/ci_build-images.sh b/podman-matrix/ci_build-images.sh index 7e7db36..8a50fc5 100755 --- a/podman-matrix/ci_build-images.sh +++ b/podman-matrix/ci_build-images.sh @@ -23,15 +23,14 @@ if ! podman image exists ${synapse_image}:${synapse_version}; then --local context=${buildfolder}/ \ --local dockerfile=${buildfolder}/docker/ \ --output type=oci,name="${synapse_image}:${synapse_version}" | \ - podman image load && + podman image load || retval=false podman container rm --volumes --force buildkitd && - podman image rm docker.io/moby/buildkit:${buildkitd_version} - } || retval=false + podman image rm --force docker.io/moby/buildkit:${buildkitd_version} + } rm -rf ${buildfolder} eval $retval else echo "Image ${synapse_image}:${synapse_version} already built" - false fi && oci_push_to_registry ${synapse_image}:${synapse_version} diff --git a/podman-peerjs/ci_build-images.sh b/podman-peerjs/ci_build-images.sh index 6c76cec..743f10f 100755 --- a/podman-peerjs/ci_build-images.sh +++ b/podman-peerjs/ci_build-images.sh @@ -17,9 +17,10 @@ if ! podman image exists ${upstream_images}:${version}; then --label org.opencontainers.image.source='https://github.com/peers/peerjs-server' \ --label org.opencontainers.image.title='PeerServer' \ --label org.opencontainers.image.url='https://peerjs.com' \ - -t ${upstream_images}:${version} ${buildfolder}/ && - podman image rm -f $(podman image list -a -q -- docker.io/library/node) && + -t ${upstream_images}:${version} ${buildfolder}/ || retval=false + podman image rm -f $(podman image list -a -q -- docker.io/library/node) rm -rf ${buildfolder} + eval $retval else echo "Image ${upstream_images}:${version} already built" fi && diff --git a/podman-privatebin/ci_build_images.sh b/podman-privatebin/ci_build_images.sh index 7e80f69..e6cd4fe 100755 --- a/podman-privatebin/ci_build_images.sh +++ b/podman-privatebin/ci_build_images.sh @@ -10,10 +10,11 @@ ensure_not_root if ! podman image exists ${privatebin_image}:${privatebin_version}; then git clone -b ${privatebin_version} --depth=1 https://github.com/PrivateBin/docker-nginx-fpm-alpine && sed -i "s#mv cfg lib tpl vendor /srv#mv cfg lib tpl vendor /srv \&\& sed -i \\'/Content-Security-Policy\\\|X-XSS-Protection\\\|X-Frame-Options\\\|X-Content-Type-Options/d\\' /srv/lib/Controller.php#" docker-nginx-fpm-alpine/Dockerfile && - podman image build -t "${privatebin_image}":"${privatebin_version}" docker-nginx-fpm-alpine && + podman image build -t "${privatebin_image}":"${privatebin_version}" docker-nginx-fpm-alpine || retval=false rm -rf docker-nginx-fpm-alpine + eval $retval else echo "Image ${privatebin_image}:${privatebin_version} already built" -fi +fi && oci_push_to_registry ${privatebin_image}:${privatebin_version} diff --git a/podman-seafile/ci_build-images.sh b/podman-seafile/ci_build-images.sh index a27b0c2..8e8df05 100755 --- a/podman-seafile/ci_build-images.sh +++ b/podman-seafile/ci_build-images.sh @@ -11,20 +11,21 @@ buildfolder=/tmp/seafile-$$ if ! podman image exists ${seafile_image}:${seafile_release}; then mkdir ${buildfolder} && - git clone --depth=1 https://github.com/haiwen/seafile-docker.git ${buildfolder}/ && - sed_in_place "^FROM phusion" "FROM docker.io/phusion" ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && - sed_in_place "SEAFILE_VERSION=" "SEAFILE_VERSION=${seafile_release}" ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && - sed_in_place "pip -i https://pypi.tuna.tsinghua.edu.cn/simple/" "pip" ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && - sed_in_place " -i https://pypi.tuna.tsinghua.edu.cn/simple/" " " ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && - sed_in_place 'wget https://seafile-downloads.oss-cn-shanghai.aliyuncs.com' 'wget -q https://download.seadrive.org' ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && - sed_in_place 'tar -zxvf' 'tar -zxf' ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && - podman image build -t ${seafile_image}:${seafile_release} \ + git clone --depth=1 https://github.com/haiwen/seafile-docker.git ${buildfolder}/ && { + sed_in_place "^FROM phusion" "FROM docker.io/phusion" ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && + sed_in_place "SEAFILE_VERSION=" "SEAFILE_VERSION=${seafile_release}" ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && + sed_in_place "pip -i https://pypi.tuna.tsinghua.edu.cn/simple/" "pip" ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && + sed_in_place " -i https://pypi.tuna.tsinghua.edu.cn/simple/" " " ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && + sed_in_place 'wget https://seafile-downloads.oss-cn-shanghai.aliyuncs.com' 'wget -q https://download.seadrive.org' ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && + sed_in_place 'tar -zxvf' 'tar -zxf' ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile && + podman image build -t ${seafile_image}:${seafile_release} \ -f ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile \ - ${buildfolder} && - podman image rm -f $(podman image list -a -q -- phusion/baseimage) + ${buildfolder} || retval=false + podman image rm -f $(podman image list -a -q -- phusion/baseimage) } rm -rf ${buildfolder} + eval $retval else echo "Image ${seafile_image}:${seafile_release} already built" -fi +fi && oci_push_to_registry ${seafile_image}:${seafile_release} diff --git a/podman-vaultwarden/ci_build-images.sh b/podman-vaultwarden/ci_build-images.sh index 587b8d5..fed66ec 100755 --- a/podman-vaultwarden/ci_build-images.sh +++ b/podman-vaultwarden/ci_build-images.sh @@ -16,15 +16,16 @@ if ! podman image exists ${vaultwarden_image}:${vaultwarden_version}; then sed_in_place "^FROM blackdex/rust-musl" "FROM docker.io/blackdex/rust-musl" ${buildfolder}/docker/amd64/Dockerfile.alpine sed_in_place "^FROM alpine" "FROM docker.io/library/alpine" ${buildfolder}/docker/amd64/Dockerfile.alpine TMPDIR=${HOME} podman image build -t ${vaultwarden_image}:${vaultwarden_version} -f ${buildfolder}/docker/amd64/Dockerfile.alpine ${buildfolder} - } + } || retval=false rm -rf ${buildfolder} podman image prune -a -f --filter dangling=true podman image prune -a -f --filter intermediate=true podman image rm -f $(podman image list -a -q -- vaultwarden/web-vault) podman image rm -f $(podman image list -a -q -- docker.io/blackdex/rust-musl) podman image rm -f $(podman image list -a -q -- dockerio/library/alpine) + eval $retval else echo "Image ${vaultwarden_image}:${vaultwarden_version} already built" -fi +fi && oci_push_to_registry ${vaultwarden_image}:${vaultwarden_version}