postgresql-citus-patroni-image/build-scripts/image-base.sh

52 lines
1.3 KiB
Bash
Raw Normal View History

2024-08-13 09:20:08 +03:00
#!/bin/sh
set -ef
cd "$(dirname "$0")/.."
set -a
BUILDAH_FORMAT="${BUILDAH_FORMAT:-docker}"
BUILDAH_ISOLATION="${BUILDAH_ISOLATION:-chroot}"
BUILDAH_NETWORK="${BUILDAH_NETWORK:-host}"
set +a
2024-12-04 21:46:38 +03:00
PYTHONTAG="${PYTHONTAG:-3.11.10-slim-bookworm}"
2024-08-13 09:20:08 +03:00
grab_site_packages() {
podman run \
--pull=always --rm \
--entrypoint='[]' \
--user=nobody:nogroup \
-e LANG=C.UTF-8 \
-e LC_ALL=C.UTF-8 \
-e MALLOC_ARENA_MAX=2 \
-e PYTHONUNBUFFERED=1 \
-e PYTHONDONTWRITEBYTECODE=1 \
"$1" \
python3 -c 'import site;print(site.getsitepackages()[0])'
}
PYTHON_SITE_PACKAGES=$(grab_site_packages "docker.io/python:${PYTHONTAG}")
[ -n "${PYTHON_SITE_PACKAGES:?}" ]
2024-12-04 21:17:59 +03:00
img="docker.io/rockdrilla/postgresql:base-v2"
2024-08-13 09:20:08 +03:00
buildah bud \
-f ./Dockerfile.base \
-t "${img}" \
--pull=missing --no-cache --squash \
--build-arg "PYTHONTAG=${PYTHONTAG}" \
--env "PYTHON_SITE_PACKAGES=${PYTHON_SITE_PACKAGES}" \
--unsetenv GPG_KEY \
--unsetenv PYTHON_PIP_VERSION \
--unsetenv PYTHON_SETUPTOOLS_VERSION \
--unsetenv PYTHON_GET_PIP_SHA256 \
--unsetenv PYTHON_GET_PIP_URL \
c=$(buildah from --pull=never "${img}") || true
if [ -z "$c" ] ; then
buildah rmi -f "${img}"
exit 1
fi
buildah config --created-by /usr/local/share/Dockerfile.base "$c"
buildah commit --rm --squash "$c" "${img}"