99#
1010ARG LINUX_VERSION=9.3
1111ARG BUILDPLATFORM=linux/amd64
12- FROM --platform=$BUILDPLATFORM almalinux:${LINUX_VERSION}
12+ FROM --platform=$BUILDPLATFORM almalinux:${LINUX_VERSION} AS packages
13+
14+ RUN echo "tsflags=nodocs" >> /etc/dnf/dnf.conf && \
15+ echo "clean_requirements_on_remove=true" >> /etc/dnf/dnf.conf
1316
1417RUN dnf upgrade --refresh -y && \
1518 dnf install -y \
@@ -20,12 +23,6 @@ RUN dnf upgrade --refresh -y && \
2023 glibc-langpack-en \
2124 gcc
2225
23- RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
24-
25- ENV LANG=en_US.UTF-8
26- ENV LANGUAGE=en_US:en
27- ENV LC_ALL=en_US.UTF-8
28-
2926# EPEL: Extra Packages for Enterprise Linux 9
3027# `epel-release` is not recent/complete enough, as some packages below are missing
3128RUN dnf config-manager --set-enabled crb && \
@@ -60,23 +57,32 @@ RUN dnf install -y \
6057 iotop iftop \
6158 tcpdump bind-utils
6259
63- # Symlink Python
64- RUN ln -sfn /usr/bin/python3 /usr/bin/python
65- # `python3-packaging` is installed by `yum` and it causes issues with `pip` installations
66- RUN yum remove python3-packaging -y
67- RUN pip3 install --upgrade pip pipenv wheel
60+ # `python3-packaging` is installed by `dnf` and it causes issues with `pip` installations
61+ RUN dnf remove python3-packaging -y
6862
6963# Install Node.js
7064RUN curl -fsSL https://rpm.nodesource.com/setup_22.x | bash - && \
7165 dnf -y install nodejs
7266
73- # Reduce image size: clean up caches, remove RPM db files
74- RUN dnf clean all && \
75- rm -rf \
76- /var/cache/dnf \
77- /var/lib/rpm/__db* \
78- /var/lib/rpm/rpmdb.sqlite \
79- /var/lib/rpm/Packages
67+ # Remove unrequired packages
68+ RUN dnf autoremove -y
69+
70+ FROM --platform=$BUILDPLATFORM almalinux:${LINUX_VERSION}
71+
72+ ENV LANG en_US.UTF-8
73+ ENV LANGUAGE en_US:en
74+ ENV LC_ALL en_US.UTF-8
75+
76+ # Copy binaries from base image avoiding large dnf cache history
77+ COPY --from=packages /usr/ /usr/
78+ COPY --from=packages /etc/ /etc/
79+ COPY --from=packages /var/lib/rpm/rpmdb.sqlite /var/lib/rpm/rpmdb.sqlite
80+
81+ RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
82+
83+ # Symlink Python
84+ RUN ln -sfn /usr/bin/python3 /usr/bin/python
85+ RUN pip3 install --no-cache-dir --upgrade pip pipenv wheel
8086
8187# Create working directory
8288ENV WORKING_DIR=/opt/invenio
0 commit comments