bette logic in build script : dont try to push to registry on failure

This commit is contained in:
Gitouche 2023-07-28 23:08:44 +02:00
parent 402a178843
commit 36b8d09311
8 changed files with 40 additions and 34 deletions

View file

@ -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/ podman image build -t "${framadate_image}":"${framadate_version}" --build-arg=version="${framadate_version}" container/
else else
echo "Image ${framadate_image}:${framadate_version} already built" echo "Image ${framadate_image}:${framadate_version} already built"
fi fi &&
oci_push_to_registry ${framadate_image}:${framadate_version} oci_push_to_registry ${framadate_image}:${framadate_version}

View file

@ -14,15 +14,17 @@ if ! podman image exists ${gitea_image}:${gitea_version}; then
git clone -b v${gitea_version} --depth=1 https://codeberg.org/forgejo/forgejo/ ${buildfolder} && { git clone -b v${gitea_version} --depth=1 https://codeberg.org/forgejo/forgejo/ ${buildfolder} && {
TMPDIR=${HOME} podman image build \ TMPDIR=${HOME} podman image build \
--label org.opencontainers.image.version="${gitea_version}" \ --label org.opencontainers.image.version="${gitea_version}" \
-t ${gitea_image}:${gitea_version} -f ${buildfolder}/Dockerfile ${buildfolder} -t ${gitea_image}:${gitea_version} \
} -f ${buildfolder}/Dockerfile ${buildfolder} || retval=false
rm -rf ${buildfolder}
podman image prune -a -f --filter dangling=true podman image prune -a -f --filter dangling=true
podman image prune -a -f --filter intermediate=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/golang)
podman image rm -f $(podman image list -a -q -- docker.io/library/alpine) podman image rm -f $(podman image list -a -q -- docker.io/library/alpine)
}
rm -rf ${buildfolder}
eval $retval
else else
echo "Image ${gitea_image}:${gitea_version} already built" echo "Image ${gitea_image}:${gitea_version} already built"
fi fi &&
oci_push_to_registry ${gitea_image}:${gitea_version} oci_push_to_registry ${gitea_image}:${gitea_version}

View file

@ -13,13 +13,14 @@ if ! podman image exists ${hedgedoc_image}:${hedgedoc_version}; then
mkdir ${buildfolder} && mkdir ${buildfolder} &&
git clone --depth=1 https://github.com/hedgedoc/container ${buildfolder}/ && { git clone --depth=1 https://github.com/hedgedoc/container ${buildfolder}/ && {
podman image build -t ${hedgedoc_image}:${hedgedoc_version} -f ${buildfolder}/alpine/Dockerfile ${buildfolder}/ podman image build -t ${hedgedoc_image}:${hedgedoc_version} -f ${buildfolder}/alpine/Dockerfile ${buildfolder}/
} } || retval=false
rm -rf ${buildfolder} rm -rf ${buildfolder}
podman image prune -a -f --filter dangling=true podman image prune -a -f --filter dangling=true
podman image prune -a -f --filter intermediate=true podman image prune -a -f --filter intermediate=true
podman image rm -f $(podman image list -a -q -- docker.io/library/node) podman image rm -f $(podman image list -a -q -- docker.io/library/node)
eval $retval
else else
echo "Image ${hedgedoc_image}:${hedgedoc_version} already built" echo "Image ${hedgedoc_image}:${hedgedoc_version} already built"
fi fi &&
oci_push_to_registry ${hedgedoc_image}:${hedgedoc_version} oci_push_to_registry ${hedgedoc_image}:${hedgedoc_version}

View file

@ -23,15 +23,14 @@ if ! podman image exists ${synapse_image}:${synapse_version}; then
--local context=${buildfolder}/ \ --local context=${buildfolder}/ \
--local dockerfile=${buildfolder}/docker/ \ --local dockerfile=${buildfolder}/docker/ \
--output type=oci,name="${synapse_image}:${synapse_version}" | \ --output type=oci,name="${synapse_image}:${synapse_version}" | \
podman image load && podman image load || retval=false
podman container rm --volumes --force buildkitd && podman container rm --volumes --force buildkitd &&
podman image rm docker.io/moby/buildkit:${buildkitd_version} podman image rm --force docker.io/moby/buildkit:${buildkitd_version}
} || retval=false }
rm -rf ${buildfolder} rm -rf ${buildfolder}
eval $retval eval $retval
else else
echo "Image ${synapse_image}:${synapse_version} already built" echo "Image ${synapse_image}:${synapse_version} already built"
false
fi && fi &&
oci_push_to_registry ${synapse_image}:${synapse_version} oci_push_to_registry ${synapse_image}:${synapse_version}

View file

@ -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.source='https://github.com/peers/peerjs-server' \
--label org.opencontainers.image.title='PeerServer' \ --label org.opencontainers.image.title='PeerServer' \
--label org.opencontainers.image.url='https://peerjs.com' \ --label org.opencontainers.image.url='https://peerjs.com' \
-t ${upstream_images}:${version} ${buildfolder}/ && -t ${upstream_images}:${version} ${buildfolder}/ || retval=false
podman image rm -f $(podman image list -a -q -- docker.io/library/node) && podman image rm -f $(podman image list -a -q -- docker.io/library/node)
rm -rf ${buildfolder} rm -rf ${buildfolder}
eval $retval
else else
echo "Image ${upstream_images}:${version} already built" echo "Image ${upstream_images}:${version} already built"
fi && fi &&

View file

@ -10,10 +10,11 @@ ensure_not_root
if ! podman image exists ${privatebin_image}:${privatebin_version}; then if ! podman image exists ${privatebin_image}:${privatebin_version}; then
git clone -b ${privatebin_version} --depth=1 https://github.com/PrivateBin/docker-nginx-fpm-alpine && 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 && 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 rm -rf docker-nginx-fpm-alpine
eval $retval
else else
echo "Image ${privatebin_image}:${privatebin_version} already built" echo "Image ${privatebin_image}:${privatebin_version} already built"
fi fi &&
oci_push_to_registry ${privatebin_image}:${privatebin_version} oci_push_to_registry ${privatebin_image}:${privatebin_version}

View file

@ -11,7 +11,7 @@ buildfolder=/tmp/seafile-$$
if ! podman image exists ${seafile_image}:${seafile_release}; then if ! podman image exists ${seafile_image}:${seafile_release}; then
mkdir ${buildfolder} && mkdir ${buildfolder} &&
git clone --depth=1 https://github.com/haiwen/seafile-docker.git ${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 "^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 "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 "pip -i https://pypi.tuna.tsinghua.edu.cn/simple/" "pip" ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile &&
@ -20,11 +20,12 @@ if ! podman image exists ${seafile_image}:${seafile_release}; then
sed_in_place 'tar -zxvf' 'tar -zxf' ${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} \ podman image build -t ${seafile_image}:${seafile_release} \
-f ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile \ -f ${buildfolder}/image/seafile_${seafile_release%.*}/Dockerfile \
${buildfolder} && ${buildfolder} || retval=false
podman image rm -f $(podman image list -a -q -- phusion/baseimage) podman image rm -f $(podman image list -a -q -- phusion/baseimage) }
rm -rf ${buildfolder} rm -rf ${buildfolder}
eval $retval
else else
echo "Image ${seafile_image}:${seafile_release} already built" echo "Image ${seafile_image}:${seafile_release} already built"
fi fi &&
oci_push_to_registry ${seafile_image}:${seafile_release} oci_push_to_registry ${seafile_image}:${seafile_release}

View file

@ -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 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 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} TMPDIR=${HOME} podman image build -t ${vaultwarden_image}:${vaultwarden_version} -f ${buildfolder}/docker/amd64/Dockerfile.alpine ${buildfolder}
} } || retval=false
rm -rf ${buildfolder} rm -rf ${buildfolder}
podman image prune -a -f --filter dangling=true podman image prune -a -f --filter dangling=true
podman image prune -a -f --filter intermediate=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 -- 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 -- docker.io/blackdex/rust-musl)
podman image rm -f $(podman image list -a -q -- dockerio/library/alpine) podman image rm -f $(podman image list -a -q -- dockerio/library/alpine)
eval $retval
else else
echo "Image ${vaultwarden_image}:${vaultwarden_version} already built" echo "Image ${vaultwarden_image}:${vaultwarden_version} already built"
fi fi &&
oci_push_to_registry ${vaultwarden_image}:${vaultwarden_version} oci_push_to_registry ${vaultwarden_image}:${vaultwarden_version}