Files
EventHubBack/docker/scripts/collect-runtime-libs.sh
T
aleksey e8464b3a8b
CI / test (push) Successful in 7m42s
Add shared Erlang builder/runtime base images from registry.
Publish erlang-builder and erlang-runtime as :latest, use them in prod and API test builds, auto-collect NIF libs, and sync CI to pull/push bases before eventhub build.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 12:25:42 +03:00

49 lines
1.2 KiB
Bash

#!/bin/sh
# Собирает .so, нужные NIF/priv из release (ldd), для runtime-слоя.
# Исключает musl/libc — их даёт базовый alpine-образ.
# Usage: collect-runtime-libs.sh <release_dir> <output_root>
set -eu
RELEASE="${1:?release_dir}"
OUT="${2:?output_root}"
mkdir -p "${OUT}"
is_base_lib() {
case "$1" in
/lib/ld-musl-*|*/ld-musl-*|*/libc.musl-*) return 0 ;;
esac
return 1
}
copy_lib() {
lib="$1"
[ -e "${lib}" ] || return 0
is_base_lib "${lib}" && return 0
dest="${OUT}${lib}"
mkdir -p "$(dirname "${dest}")"
if [ -L "${lib}" ]; then
cp -a "${lib}" "${dest}"
else
cp -L "${lib}" "${dest}" 2>/dev/null || cp "${lib}" "${dest}"
fi
}
# shellcheck disable=SC2044
for so in $(find "${RELEASE}" -name '*.so' 2>/dev/null); do
ldd "${so}" 2>/dev/null | while read -r line; do
case "${line}" in
*'=>'*)
lib=$(echo "${line}" | awk '{print $3}')
[ -n "${lib}" ] && copy_lib "${lib}"
;;
/lib/*|/usr/lib/*)
lib=$(echo "${line}" | awk '{print $1}')
copy_lib "${lib}"
;;
esac
done
done
echo "collect-runtime-libs: $(find "${OUT}" -name '*.so*' 2>/dev/null | wc -l) files under ${OUT}"