2022-08-15 08:31:39 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
2023-07-29 07:14:59 +00:00
|
|
|
source "${ABSDIR}"/../functions.sh
|
|
|
|
source "${ABSDIR}"/vars.sh
|
2022-08-15 08:31:39 +00:00
|
|
|
|
|
|
|
ensure_pwd_is_scriptdir
|
|
|
|
ensure_not_root
|
|
|
|
|
2023-10-28 15:41:15 +00:00
|
|
|
buildfolder=/tmp/privatebin-$$
|
|
|
|
|
2022-08-15 08:31:39 +00:00
|
|
|
if ! podman image exists ${privatebin_image}:${privatebin_version}; then
|
2023-10-28 15:41:15 +00:00
|
|
|
if git clone -b ${privatebin_version} --depth=1 https://github.com/PrivateBin/docker-nginx-fpm-alpine ${buildfolder} ; then
|
2024-12-21 20:58:06 +00:00
|
|
|
arg_release=$(grep 'ARG RELEASE' ${buildfolder}/Dockerfile | cut -d= -f2)
|
|
|
|
read type tag_sha < <(echo $(curl -s "https://api.github.com/repos/PrivateBin/PrivateBin/git/ref/tags/${arg_release}" | jq -r '.object.type,.object.sha'))
|
|
|
|
if [ $type == "commit" ]; then
|
|
|
|
sha=$tag_sha
|
|
|
|
echo "commit sha: $tag_sha"
|
|
|
|
else
|
|
|
|
sha=$(curl -s "https://api.github.com/repos/PrivateBin/PrivateBin/git/tags/$tag_sha" | jq '.object.sha')
|
|
|
|
echo "commit sha: $sha"
|
|
|
|
fi
|
2023-10-28 17:10:34 +00:00
|
|
|
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#" ${buildfolder}/Dockerfile &&
|
2023-10-29 14:32:34 +00:00
|
|
|
TMPDIR=${HOME} podman image build \
|
2024-12-21 21:01:59 +00:00
|
|
|
--label "org.opencontainers.image.revision=${sha}" \
|
2024-12-21 19:47:39 +00:00
|
|
|
-t "${privatebin_image}":"${privatebin_version}" \
|
|
|
|
${buildfolder} || retval=false
|
2023-10-28 15:41:15 +00:00
|
|
|
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/alpine)
|
2023-07-29 07:14:59 +00:00
|
|
|
fi
|
2023-10-28 15:41:15 +00:00
|
|
|
rm -rf ${buildfolder}
|
2023-07-29 07:14:59 +00:00
|
|
|
eval "$retval"
|
2022-08-15 08:31:39 +00:00
|
|
|
else
|
|
|
|
echo "Image ${privatebin_image}:${privatebin_version} already built"
|
2023-07-28 21:08:44 +00:00
|
|
|
fi &&
|
2022-08-15 08:31:39 +00:00
|
|
|
|
|
|
|
oci_push_to_registry ${privatebin_image}:${privatebin_version}
|