@@ -477,7 +477,7 @@ RUN if [ "${ENABLE_GDP}" = "True" ]; then \
477477 xorg-x11-server-Xvfb \
478478 && dnf clean all \
479479 && rm -fr /var/cache/dnf \
480- && pip2 install pdfkit; \
480+ && pip2 install --no-cache-dir pdfkit; \
481481 if [ "${WITH_PY3}" = "True" ]; then \
482482 echo "install py3 deps" && \
483483 dnf update -y && \
@@ -493,8 +493,8 @@ RUN if [ "${ENABLE_GDP}" = "True" ]; then \
493493# Prepare mod WSGI for py2 (no longer in dnf here)
494494# See standalone notes on https://pypi.org/project/mod-wsgi/
495495#RUN dnf install -y apr-devel && dnf clean all && rm -fr /var/cache/dnf
496- #RUN pip2 install mod_wsgi-standalone
497- RUN pip2 install mod_wsgi && \
496+ #RUN pip2 install --no-cache-dir mod_wsgi-standalone
497+ RUN pip2 install --no-cache-dir mod_wsgi && \
498498 #find /usr/lib64/python2.7/site-packages/mod_wsgi && \
499499 cp /usr/lib64/python2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so \
500500 /etc/httpd/modules/mod_wsgi.so && \
@@ -540,11 +540,11 @@ RUN if [ "$BUILD_MOD_AUTH_OPENID" = "True" -o "$ENABLE_SELF_SIGNED_CERTS" = "Tru
540540 && yumdownloader -y --enablerepo=epel7-source --source --resolve --destdir /root/rpmbuild/SRPMS libopkele \
541541 && rpm -ivh /root/rpmbuild/SRPMS/libopkele-*.src.rpm \
542542 # Optionally pull more recent gcc4.9 patch from Debian on rocky8+ (local copy in patches)
543- && wget -O /root/rpmbuild/SOURCES/fix-ftbfs-gcc4.9.diff https://sources.debian.org/data/main/libo/libopkele/2.0.4%2Bgit20140305.9651b55-4/debian/patches/fix-ftbfs-gcc4.9.diff \
543+ && wget -q - O /root/rpmbuild/SOURCES/fix-ftbfs-gcc4.9.diff https://sources.debian.org/data/main/libo/libopkele/2.0.4%2Bgit20140305.9651b55-4/debian/patches/fix-ftbfs-gcc4.9.diff \
544544 # Pull the more recent required OpenSSL-1.1 patch from Debian on rocky8+ (local copy in patches)
545- && wget -O /root/rpmbuild/SOURCES/fix-openssl-1.1.0.diff https://sources.debian.org/data/main/libo/libopkele/2.0.4%2Bgit20140305.9651b55-4/debian/patches/fix-openssl-1.1.0.diff \
545+ && wget -q - O /root/rpmbuild/SOURCES/fix-openssl-1.1.0.diff https://sources.debian.org/data/main/libo/libopkele/2.0.4%2Bgit20140305.9651b55-4/debian/patches/fix-openssl-1.1.0.diff \
546546 # Pull patch from own repo to rpmbuild with Debian patches on rocky8+ (local copy in patches)
547- && wget -O /tmp/rpmbuild-opkele-with-gcc4.9-openssl-1.1.0-patches.diff https://github.com/ucphhpc/docker-migrid/raw/master/patches/rpmbuild-opkele-with-gcc4.9-openssl-1.1.0-patches.diff \
547+ && wget -q - O /tmp/rpmbuild-opkele-with-gcc4.9-openssl-1.1.0-patches.diff https://github.com/ucphhpc/docker-migrid/raw/master/patches/rpmbuild-opkele-with-gcc4.9-openssl-1.1.0-patches.diff \
548548 && cd /root && patch -p 0 < /tmp/rpmbuild-opkele-with-gcc4.9-openssl-1.1.0-patches.diff && cd - \
549549 # TODO: is this security crippling needed or a matter of proper apache proxying?
550550 # Disable Apache OpenID ssl-certificate verification if self-signed
@@ -628,7 +628,8 @@ ENV USER=mig
628628ENV GROUP=mig
629629
630630RUN groupadd -g $GID $USER
631- RUN useradd -u $UID -g $GID -ms /bin/bash $USER
631+ # NOTE: use -l to avoid excessively large image (hadolint hint)
632+ RUN useradd -l -u $UID -g $GID -ms /bin/bash $USER
632633
633634# MiG environment
634635ENV MIG_ROOT=/home/$USER
@@ -703,8 +704,8 @@ RUN if [ ! -e "${CERT_DIR}/.persistent" ]; then \
703704 && chown $USER:$GROUP combined.pem \
704705 && chown $USER:$GROUP server.ca.pem \
705706 && ssh-keygen -y -f combined.pem > combined.pub \
706- && chown 0:0 *.key server.crt ca.pem \
707- && chmod 400 *.key server.crt ca.pem combined.pem server.ca.pem \
707+ && chown 0:0 ./ *.key server.crt ca.pem \
708+ && chmod 400 ./ *.key server.crt ca.pem combined.pem server.ca.pem \
708709 && openssl x509 -noout -fingerprint -sha256 -in combined.pem | \
709710 sed 's/.* Fingerprint=//g' > combined.pem.sha256 \
710711 && ssh-keygen -l -E md5 -f combined.pub | \
@@ -795,16 +796,16 @@ USER root
795796# Prepare py2 dependencies no longer in dnf or just outdated there
796797
797798# NOTE: use jsonrpclib and pysendfile from pip both for py2 and py3 here
798- RUN pip2 install 'jsonrpclib<0.2' pysendfile; \
799+ RUN pip2 install --no-cache-dir 'jsonrpclib<0.2' pysendfile; \
799800 if [ "${WITH_PY3}" = "True" ]; then \
800- pip3 install 'jsonrpclib<0.2' pysendfile; \
801+ pip3 install --no-cache-dir 'jsonrpclib<0.2' pysendfile; \
801802 fi;
802803
803804# NOTE: recent paramiko is required for modern host key algo
804805# NOTE: paramiko is unavailable for py2 in dnf here so always install it with pip2
805806RUN if [ "${UPGRADE_PARAMIKO}" = "True" ]; then \
806807 # NOTE: paramiko-3.0.0 & pyOpenSSL-22.0 dropped python2 support
807- pip2 install 'pyOpenSSL<22' 'paramiko<3'; \
808+ pip2 install --no-cache-dir 'pyOpenSSL<22' 'paramiko<3'; \
808809 if [ "${WITH_PY3}" = "True" ]; then \
809810 # NOTE: paramiko-3.0.0 & pyOpenSSL-22.0 deps dropped python3.6 support
810811 # NOTE: a newer setuptools MAY be needed and setuptools_rust MUST be
@@ -815,18 +816,18 @@ RUN if [ "${UPGRADE_PARAMIKO}" = "True" ]; then \
815816 # /usr/local, which is now the default install location for
816817 # pip3. Thus, we force pip3 to install the paramiko plus
817818 # dependencies specifically into /usr instead.
818- #pip3 install -U setuptools; \
819+ #pip3 install --no-cache-dir - U setuptools; \
819820 # NOTE: explicitly install typing-extensions 3.7 to avoid the
820821 # compatibility issues mentioned in note above.
821822 # Just use distro package on Rocky 8.
822- #pip3 install 'typing-extensions<3.8'; \
823- pip3 install setuptools_rust; \
824- pip3 install --prefix=$(python3-config --prefix) pynacl bcrypt cryptography \
823+ #pip3 install --no-cache-dir 'typing-extensions<3.8'; \
824+ pip3 install --no-cache-dir setuptools_rust; \
825+ pip3 install --no-cache-dir -- prefix=$(python3-config --prefix) pynacl bcrypt cryptography \
825826 'pyOpenSSL<22' 'paramiko<3'; \
826827 fi; \
827828 else \
828829 # NOTE: mimic python3 dnf versions in this case
829- pip2 install 'pyOpenSSL<20' 'cryptography<3.3' 'paramiko<2.5'; \
830+ pip2 install --no-cache-dir 'pyOpenSSL<20' 'cryptography<3.3' 'paramiko<2.5'; \
830831 fi;
831832
832833# NOTE: openstackclient is unavailable in dnf here so always install with pip
@@ -836,40 +837,40 @@ RUN if [ "${UPGRADE_PARAMIKO}" = "True" ]; then \
836837# NOTE: openstacksdk-1.5 may have introduced typing conflicts here
837838# NOTE: cinderclient-6.x introduced python-requests conflict on py2 here
838839RUN if [ "${ENABLE_CLOUD}" = "True" ]; then \
839- pip2 install PyYAML==3.12 'openstacksdk<2' 'python-cinderclient<6' \
840+ pip2 install --no-cache-dir PyYAML==3.12 'openstacksdk<2' 'python-cinderclient<6' \
840841 'python-openstackclient<5'; \
841842 if [ -n "${OPENSTACKSDK_VERSION_OVERRIDE}" ]; then \
842- pip2 install "openstacksdk==${OPENSTACKSDK_VERSION_OVERRIDE}" ; \
843+ pip2 install --no-cache-dir "openstacksdk==${OPENSTACKSDK_VERSION_OVERRIDE}" ; \
843844 fi; \
844845 if [ "${WITH_PY3}" = "True" ]; then \
845- pip3 install PyYAML==3.12 'openstacksdk<1.5' 'python-openstackclient<6'; \
846+ pip3 install --no-cache-dir PyYAML==3.12 'openstacksdk<1.5' 'python-openstackclient<6'; \
846847 if [ -n "${OPENSTACKSDK_VERSION_OVERRIDE}" ]; then \
847- pip3 install "openstacksdk==${OPENSTACKSDK_VERSION_OVERRIDE}" ; \
848+ pip3 install --no-cache-dir "openstacksdk==${OPENSTACKSDK_VERSION_OVERRIDE}" ; \
848849 fi; \
849850 fi; \
850851 fi;
851852
852853# Prepare OpenID (python-openid for py2 and python-openid2 for py3)
853- #RUN pip2 install python-openid
854- RUN pip2 install https://github.com/openid/python-openid/archive/master.zip
854+ #RUN pip2 install --no-cache-dir python-openid
855+ RUN pip2 install --no-cache-dir https://github.com/openid/python-openid/archive/master.zip
855856RUN if [ "${WITH_PY3}" = "True" ]; then \
856- pip3 install python-openid2; \
857+ pip3 install --no-cache-dir python-openid2; \
857858 fi;
858859
859860# Modules required by grid_events.py
860861# NOTE: watchdog-1.0 dropped python2 support
861- RUN pip2 install 'watchdog<1.0' scandir
862+ RUN pip2 install --no-cache-dir 'watchdog<1.0' scandir
862863RUN if [ "${WITH_PY3}" = "True" ]; then \
863- pip3 install watchdog scandir; \
864+ pip3 install --no-cache-dir watchdog scandir; \
864865 fi;
865866
866867# Modules required by grid_webdavs
867868# NOTE: on python 2 we require either wsgidav 1.3 bundled with cherrypy or
868869# wsgidav 3.x using standalone cheroot
869870RUN if [ "${MODERN_WSGIDAV}" = "False" ]; then \
870- pip2 install 'wsgidav<2'; \
871+ pip2 install --no-cache-dir 'wsgidav<2'; \
871872 else \
872- pip2 install 'more-itertools<6' 'jaraco.functools<3' 'jinja2<3' \
873+ pip2 install --no-cache-dir 'more-itertools<6' 'jaraco.functools<3' 'jinja2<3' \
873874 'markupsafe<2' 'pyyaml<6' 'cheroot<10.0.1' 'wsgidav<4'; \
874875 fi;
875876RUN if [ "${WITH_PY3}" = "True" ]; then \
@@ -878,51 +879,51 @@ RUN if [ "${WITH_PY3}" = "True" ]; then \
878879 # IMPORTANT: use cheroot before 10.0.1 as it currently crashes webdavs
879880 # One can trigger the crash with a simple testssl.sh run
880881 # TODO: investigate if the problem is in cheroot, wsgidav or migrid.
881- pip3 install 'cheroot<10.0.1' 'wsgidav>=4.1.0'; \
882+ pip3 install --no-cache-dir 'cheroot<10.0.1' 'wsgidav>=4.1.0'; \
882883 fi;
883884# Prefer sslkeylog as session tracking helper in webdavs daemon if available.
884885# Automatic fallback to our _sslsession C-extension when not.
885- RUN python2 -V 2>&1 | egrep -q 'Python 2\.7\.[0-8]$' || pip2 install sslkeylog
886+ RUN python2 -V 2>&1 | egrep -q 'Python 2\.7\.[0-8]$' || pip2 install --no-cache-dir sslkeylog
886887RUN if [ "${WITH_PY3}" = "True" ]; then \
887- pip3 install sslkeylog ; \
888+ pip3 install --no-cache-dir sslkeylog ; \
888889 fi;
889890
890891# Modules required by grid_ftps
891892# NOTE: relies on pyOpenSSL and Cryptography from yum/dnf for now
892893# NOTE: python-3.6 fails with unsupported OpenSSL attribute in pyftpdlib-2.x
893- RUN pip2 install 'pyftpdlib<2.0'
894+ RUN pip2 install --no-cache-dir 'pyftpdlib<2.0'
894895RUN if [ "${WITH_PY3}" = "True" ]; then \
895- pip3 install 'pyftpdlib<2.0'; \
896+ pip3 install --no-cache-dir 'pyftpdlib<2.0'; \
896897 fi;
897898
898899# Modules required by grid_X IO daemons (not available in yum/dnf for python3)
899900# IMPORTANT: install in main python site-packages to work with 'python -s'
900901# Otherwise sftpsubsys will fail to import it because the /usr/local
901902# dir used as prefix by default in pip is outside sys.path
902- RUN pip2 install --prefix=$(python2-config --prefix) cracklib
903+ RUN pip2 install --no-cache-dir -- prefix=$(python2-config --prefix) cracklib
903904RUN if [ "${WITH_PY3}" = "True" ]; then \
904- pip3 install --prefix=$(python3-config --prefix) cracklib; \
905+ pip3 install --no-cache-dir -- prefix=$(python3-config --prefix) cracklib; \
905906 fi;
906907
907908# Module required to run pytests
908909# NOTE: pytest-5.0 dropped python2 support
909- RUN pip2 install 'pytest<5.0'
910+ RUN pip2 install --no-cache-dir 'pytest<5.0'
910911RUN if [ "${WITH_PY3}" = "True" ]; then \
911- pip3 install pytest; \
912+ pip3 install --no-cache-dir pytest; \
912913 fi;
913914
914915# Modules required by 2FA
915916# NOTE: pyotp-2.4 dropped python2 support
916- RUN pip2 install 'pyotp<2.4'
917+ RUN pip2 install --no-cache-dir 'pyotp<2.4'
917918RUN if [ "${WITH_PY3}" = "True" ]; then \
918- pip3 install pyotp; \
919+ pip3 install --no-cache-dir pyotp; \
919920 fi;
920921
921922# Modules required for smart country selection
922923# NOTE: iso3361-2.0 dropped python2 support
923- RUN pip2 install 'iso3166<2.0'
924+ RUN pip2 install --no-cache-dir 'iso3166<2.0'
924925RUN if [ "${WITH_PY3}" = "True" ]; then \
925- pip3 install iso3166; \
926+ pip3 install --no-cache-dir iso3166; \
926927 fi;
927928
928929# Modules required for email validation (not available in yum/dnf for python2)
@@ -931,41 +932,41 @@ RUN if [ "${WITH_PY3}" = "True" ]; then \
931932# https://github.com/JoshData/python-email-validator/issues/91
932933# NOTE: email-validator relies on dnspython which dropped py2 support in the
933934# 2.x series, so we force a previous version there.
934- RUN pip2 install 'dnspython<2.0' 'email-validator<1.3.0'
935+ RUN pip2 install --no-cache-dir 'dnspython<2.0' 'email-validator<1.3.0'
935936# IMPORTANT: install in main python site-packages to work with 'python -s'
936937# Otherwise sftpsubsys will fail to import it because the /usr/local
937938# dir used as prefix by default in pip is outside sys.path
938939#RUN if [ "${WITH_PY3}" = "True" ]; then \
939- # pip3 install --prefix=$(python3-config --prefix) email-validator; \
940+ # pip3 install --no-cache-dir -- prefix=$(python3-config --prefix) email-validator; \
940941# fi;
941942
942943# Modules required for Trac integration
943944RUN if [ -n "${TRAC_ADMIN_PATH}" ]; then \
944945 echo "install Trac and plugins" \
945- && pip2 install Trac TracMercurial TracWikiPrint TracGraphviz TracFullBlog TracWikiCssPlugin; \
946+ && pip2 install --no-cache-dir Trac TracMercurial TracWikiPrint TracGraphviz TracFullBlog TracWikiCssPlugin; \
946947 if [ "${WITH_PY3}" = "True" ]; then \
947- pip3 install Trac TracWikiPrint TracGraphviz TracFullBlog TracWikiCssPlugin \
948+ pip3 install --no-cache-dir Trac TracWikiPrint TracGraphviz TracFullBlog TracWikiCssPlugin \
948949 # IMPORTANT: Mercurial plugin is required for our repos and only recent
949950 # stable releases support current python and Trac versions.
950951 # We need 1.0.0.11+ for the default Python 3 and Trac-1.6.
951- && pip3 install 'TracMercurial>=1.0.0.11' \
952+ && pip3 install --no-cache-dir 'TracMercurial>=1.0.0.11' \
952953 # NOTE: these plugins would be nice but have gone stale and only support
953954 # older Trac versions.
954- #&& pip3 install TracStats TracMasterTickets TracDiscussion TracDownloads TracWysiwyg \
955- #&& pip3 install https://trac-hacks.org/svn/tracwysiwygplugin/0.12
955+ #&& pip3 install --no-cache-dir TracStats TracMasterTickets TracDiscussion TracDownloads TracWysiwyg \
956+ #&& pip3 install --no-cache-dir https://trac-hacks.org/svn/tracwysiwygplugin/0.12
956957 # NOTE: install more recent dev versions of those with Trac-1.6+ support
957958 # latest tag https://github.com/trac-hacks/tracstats/releases/tag/v0.6.1 is pre 1.6
958- && pip3 install https://github.com/trac-hacks/tracstats/archive/refs/heads/master.zip ; \
959+ && pip3 install --no-cache-dir https://github.com/trac-hacks/tracstats/archive/refs/heads/master.zip ; \
959960 fi; \
960961 else \
961962 echo "no Trac deps"; \
962963 fi;
963964
964965# Modules required for workflows
965966# NOTE: nbformat-5.0, nbconvert-6.0 and papermill-2.0 dropped python2 support
966- RUN pip2 install 'nbformat<5.0' 'nbconvert<6.0' 'papermill<2.0'
967+ RUN pip2 install --no-cache-dir 'nbformat<5.0' 'nbconvert<6.0' 'papermill<2.0'
967968RUN if [ "${WITH_PY3}" = "True" ]; then \
968- pip3 install nbformat nbconvert papermill; \
969+ pip3 install --no-cache-dir nbformat nbconvert papermill; \
969970 fi;
970971
971972#------------------------- next stage -----------------------------#
@@ -1485,10 +1486,10 @@ RUN cd $MIG_ROOT/mig/src/libnss-mig \
14851486# on python 2.7.9+ and 3. The sslsession module generally builds but fails at
14861487# runtime when used with OpenSSL-1.1+, however.
14871488RUN cd $MIG_ROOT/mig/src/sslsession \
1488- && pip2 install . ;
1489+ && pip2 install --no-cache-dir . ;
14891490RUN if [ "${WITH_PY3}" = "True" ]; then \
14901491 cd $MIG_ROOT/mig/src/sslsession \
1491- && pip3 install . ; \
1492+ && pip3 install --no-cache-dir . ; \
14921493 fi;
14931494
14941495RUN cp generated-confs/libnss_mig.conf /etc/ \
@@ -1690,6 +1691,9 @@ RUN if [ "${ENABLE_QUOTA}" = "True" ] \
16901691 libnl3-devel.x86_64 \
16911692 libyaml-devel \
16921693 krb5-devel.x86_64 \
1694+ && dnf clean all \
1695+ && rm -fr /var/cache/dnf \
1696+ # TODO: clean up after this download+build to avoid bloating image
16931697 && cd ${MIG_ROOT}/mig/src/pylustrequota \
16941698 && git clone git://git.whamcloud.com/fs/lustre-release.git \
16951699 && cd ${MIG_ROOT}/mig/src/pylustrequota/lustre-release \
@@ -1713,19 +1717,33 @@ FROM --platform=linux/$ARCH setup_mig_configs AS start_mig
17131717ARG DOMAIN
17141718
17151719# Reap defuncted/orphaned processes
1720+ # IMPORTANT: always verify gpg signature / use verified checksum in downloads!
17161721ARG TINI_VERSION=v0.18.0
1722+ ARG TINI_CHECKSUM=sha256:12d20136605531b09a2c2dac02ccee85e1b874eb322ef6baf7561cd93f93c855
1723+ ARG TINI_GPG_KEY=0527A9B7
1724+ # NOTE: hadolint awaits https://github.com/hadolint/language-docker/pull/92 in
1725+ # an actual release so it will currectly fail hard on the checksum arg.
1726+ # Rely solely on explicit gpg signature verification for the time being.
1727+ #ADD --checksum=${TINI_CHECKSUM} https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
17171728ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
1729+ ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc
1730+ RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys ${TINI_GPG_KEY} \
1731+ && if ! gpg --verify /tini.asc /tini ; then \
1732+ echo "FATAL: failed to verify tini binary"; \
1733+ exit 1 ; \
1734+ fi
17181735RUN chmod +x /tini
17191736ENTRYPOINT ["/tini", "--"]
17201737
1721- ADD docker-entry.sh /app/docker-entry.sh
1722- ADD migrid-httpd.env /app/migrid-httpd.env
1723- ADD migrid-httpd-init.sh /app/migrid-httpd-init.sh
1724- ADD apache-init-helper /etc/init.d/apache-minimal
1738+ # NOTE: it's recommended to use COPY over ADD except when URL/unpack is needed
1739+ COPY docker-entry.sh /app/docker-entry.sh
1740+ COPY migrid-httpd.env /app/migrid-httpd.env
1741+ COPY migrid-httpd-init.sh /app/migrid-httpd-init.sh
1742+ COPY apache-init-helper /etc/init.d/apache-minimal
17251743# NOTE: inherit explicit LANG set above for apache and migrid services
17261744RUN sed "s/#LANG=.*/LANG=${LANG}/g" /app/migrid-httpd-init.sh > /etc/sysconfig/apache-minimal
17271745RUN grep LANG /etc/sysconfig/apache-minimal > /etc/sysconfig/migrid
1728- ADD rsyslog-init-helper /etc/init.d/rsyslog-minimal
1746+ COPY rsyslog-init-helper /etc/init.d/rsyslog-minimal
17291747RUN chown $USER:$GROUP /app/docker-entry.sh \
17301748 && chmod +x /app/docker-entry.sh
17311749
0 commit comments