1
0
angie-conv-image/Dockerfile.deps

97 lines
2.9 KiB
Docker
Raw Normal View History

ARG IMAGE_VERSION
FROM docker.io/rockdrilla/angie-conv:${IMAGE_VERSION}-base AS base
2024-09-17 14:11:00 +03:00
## ---
FROM base AS build
2024-09-17 14:11:00 +03:00
SHELL [ "/bin/sh", "-ec" ]
COPY /scripts/* /usr/local/sbin/
COPY /extra-scripts/* /usr/local/sbin/
COPY /requirements.txt /tmp/
2024-09-17 14:11:00 +03:00
ENV DEV_PACKAGES='libyaml-dev'
# markupsafe, psutil
ENV CIBUILDWHEEL=1
# pyyaml
ENV PYYAML_FORCE_CYTHON=1
RUN w=$(mktemp -d) ; : "${w:?}" ; \
{ apt-mark showauto ; apt-mark showmanual ; } | sort -uV > "$w/t0" ; \
printf '%s\n' ${DEV_PACKAGES} | sort -uV > "$w/t1" ; \
apt-install.sh ${DEV_PACKAGES} ; \
{ apt-mark showauto ; apt-mark showmanual ; } | sort -uV > "$w/t2" ; \
set +e ; \
grep -Fxv -f "$w/t0" "$w/t2" > "$w/t3" ; \
grep -Fxv -f "$w/t1" "$w/t3" > "$w/t4" ; \
grep -Ev -e '-(dev|doc)$' "$w/t4" > "${PYTHON_SITE_PACKAGES}/apt-deps.txt" ; \
set -e ; \
rm -rf "$w/" ; unset w ; \
apt-install.sh build-essential ; \
pip-env.sh pip install 'cython' ; \
pip-env.sh pip install --no-binary :all: -r /tmp/requirements.txt ; \
2024-09-17 14:11:00 +03:00
pip-env.sh pip uninstall -y 'cython' ; \
python-rm-cache.sh "${PYTHON_SITE_PACKAGES}" ; \
rm -rf \
"${PYTHON_SITE_PACKAGES}/netaddr/tests" \
"${PYTHON_SITE_PACKAGES}/psutil/tests" \
; \
truncate -s 0 \
"${PYTHON_SITE_PACKAGES}/netaddr/eui/iab.idx" \
"${PYTHON_SITE_PACKAGES}/netaddr/eui/iab.txt" \
"${PYTHON_SITE_PACKAGES}/netaddr/eui/oui.txt" \
"${PYTHON_SITE_PACKAGES}/netaddr/eui/oui.idx" \
; \
2024-09-17 14:11:00 +03:00
find "${PYTHON_SITE_PACKAGES}/" -type f -name '*.so*' -exec ls -l {} + ; \
echo ; \
find "${PYTHON_SITE_PACKAGES}/" -type f -name '*.so*' -printf '%p\0' \
| sed -zE '/rust/d' \
| xargs -0r strip --verbose --strip-debug --strip-unneeded ; \
2024-09-17 14:11:00 +03:00
echo ; \
find "${PYTHON_SITE_PACKAGES}/" -type f -name '*.so*' -exec ls -l {} + ; \
apt-remove.sh build-essential ; \
apt-clean.sh
## avoid changing already present packages
RUN find "${PYTHON_SITE_PACKAGES}/" -mindepth 1 -maxdepth 1 -printf '%P\0' \
| sed -zEn \
-e '/^((pip|setuptools|wheel)-.+\.dist-info|distutils-precedence\.pth|_distutils_hack|pip|pkg_resources|setuptools|wheel)$/p' \
| env -C "${PYTHON_SITE_PACKAGES}" xargs -0r \
rm -rf
2024-09-17 14:11:00 +03:00
## ---
FROM base AS deps
SHELL [ "/bin/sh", "-ec" ]
COPY /Dockerfile.deps /usr/local/share/
## Python: site-packages
COPY --from=build /usr/local/bin/ /usr/local/bin/
COPY --from=build /${PYTHON_SITE_PACKAGES}/ /${PYTHON_SITE_PACKAGES}/
2024-09-17 14:11:00 +03:00
COPY /scripts/* /usr/local/sbin/
## install missing dependencies for Python site-packages
RUN f="${PYTHON_SITE_PACKAGES}/apt-deps.txt" ; \
[ -s "$f" ] || exit 0 ; \
xargs -a "$f" apt-install.sh ; \
apt-clean.sh
## common deps
RUN apt-install.sh \
brotli \
curl \
dumb-init \
gettext-base \
jq \
netcat-openbsd \
psmisc \
zstd \
; \
apt-clean.sh
RUN find /usr/local/sbin/ ! -type d -ls -delete ; \
jdupes -1LSpr /usr/