1
0
angie-conv-image/build-scripts/image-base.sh

54 lines
1.3 KiB
Bash
Raw Normal View History

2024-09-17 14:11:00 +03:00
#!/bin/sh
set -ef
cd "$(dirname "$0")/.."
2024-11-18 11:30:16 +03:00
IMAGE_VERSION="${IMAGE_VERSION:-v0.0.7}"
2024-09-17 14:11:00 +03:00
set -a
BUILDAH_FORMAT="${BUILDAH_FORMAT:-docker}"
BUILDAH_ISOLATION="${BUILDAH_ISOLATION:-chroot}"
BUILDAH_NETWORK="${BUILDAH_NETWORK:-host}"
set +a
PYTHONTAG="${PYTHONTAG:-3.11.10-slim-bookworm}"
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:?}" ]
img="docker.io/rockdrilla/angie-conv:${IMAGE_VERSION}-base"
2024-09-17 14:11:00 +03:00
buildah bud --network="${BUILDAH_NETWORK}" \
-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}"