# ─────────────────────────────────────────────────────────────────────────────
# YUMI GUI — glibc-2.17 build environment (CentOS 7)
#
# Purpose: compile the Nuitka onefile binary INSIDE a container whose glibc
# floor is 2.17, so the resulting binary's dynamic symbol requirements are
# actually old — not just "built with an old Python" (which does NOT lower
# the glibc requirement; that's set by whatever links the final C binary).
#
# CentOS 7 is EOL, so its normal mirrors are gone. We repoint yum at
# vault.centos.org, which still serves the frozen CentOS 7 package set.
# If that vault ever disappears, switch FROM centos:7 to
# FROM rockylinux:8 (glibc 2.28 floor — still covers Ubuntu 18.04+,
# Debian 10+, which is broad enough for almost everyone) and adjust
# package names (dnf instead of yum, no python36- prefix needed).
# ─────────────────────────────────────────────────────────────────────────────
FROM centos:7

# --- Point yum at the CentOS 7 vault (mainline mirrors are dead) -----------
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo && \
    sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo

# --- devtoolset-9: modern-enough C/C++ compiler, still glibc-2.17-targeted -
RUN yum install -y centos-release-scl && \
    sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-SCLo-scl*.repo && \
    sed -i 's|#\? *baseurl=http://mirror.centos.org/centos/7/sclo|baseurl=http://vault.centos.org/centos/7/sclo|g' /etc/yum.repos.d/CentOS-SCLo-scl*.repo && \
    yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++

# --- Python 3.6 + tkinter (EPEL) -------------------------------------------
RUN yum install -y epel-release && \
    sed -i 's/metalink/#metalink/g' /etc/yum.repos.d/epel*.repo && \
    sed -i 's|#\? *baseurl=https\?://download.fedoraproject.org/pub|baseurl=https://archives.fedoraproject.org/pub/archive|g' /etc/yum.repos.d/epel*.repo && \
    yum install -y python36 python36-devel python36-tkinter python36-pip

# --- Misc build deps ---------------------------------------------------------
RUN yum install -y which git

# --- patchelf (Nuitka onefile needs it); PyPI wheel avoids yum entirely -----
RUN python3.6 -m pip install --upgrade pip && \
    python3.6 -m pip install patchelf

# --- Nuitka + YUMI's runtime deps -------------------------------------------
RUN python3.6 -m pip install --upgrade nuitka ordered-set zstandard tkinterdnd2

# Bring devtoolset-9 onto PATH for every shell in this image (scl enable
# normally requires an interactive `scl enable` wrapper; this makes it
# unconditional so `docker run` doesn't need to know about SCL at all).
ENV PATH="/opt/rh/devtoolset-9/root/usr/bin:${PATH}"
ENV LD_LIBRARY_PATH="/opt/rh/devtoolset-9/root/usr/lib64:${LD_LIBRARY_PATH}"

WORKDIR /build
CMD ["/bin/bash"]
