services-garbaye/podman-hedgedoc/ci_build-images.sh

38 lines
1.7 KiB
Bash
Executable file

#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
source ${ABSDIR}/../functions.sh
source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir
ensure_not_root
buildfolder=/tmp/hedgedoc-$$
if ! podman image exists ${hedgedoc_image}:${hedgedoc_version}; then
mkdir ${buildfolder} &&
git clone --depth=1 https://github.com/hedgedoc/container ${buildfolder}/ && {
sed_in_place '^FROM --platform=$BUILDPLATFORM node' 'FROM --platform=$BUILDPLATFORM docker.io/library/node' ${buildfolder}/alpine/Dockerfile
sed_in_place "^FROM node" "FROM docker.io/library/node" ${buildfolder}/alpine/Dockerfile
podman image pull docker.io/moby/buildkit:latest
podman container run -d --name buildkitd --privileged docker.io/moby/buildkit:latest &&
my_buildctl --addr=podman-container://buildkitd build \
--frontend dockerfile.v0 \
--opt build-arg:VERSION=${hedgedoc_version/%-alpine/} \
--local context=${buildfolder}/ \
--local dockerfile=${buildfolder}/alpine/ \
--output type=oci,name="${hedgedoc_image}:${hedgedoc_version}" | \
podman image load &&
podman container rm --force buildkitd &&
podman image rm docker.io/moby/buildkit:latest
}
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)
else
echo "Image ${hedgedoc_image}:${hedgedoc_version} already built"
fi
oci_push_to_registry ${hedgedoc_image}:${hedgedoc_version}