# Prebuild OCCT for x86_64-unknown-linux-gnu using the manylinux_2_28 base
# image. manylinux_2_28 is AlmaLinux 8 with glibc 2.28, which gives us static
# libraries that link cleanly against any distro with glibc 2.28+ (Ubuntu
# 18.10+, Debian 10+, RHEL/Rocky/AlmaLinux 8+, Fedora 29+, Arch, openSUSE
# Leap 15.1+). Same portability strategy Python wheels use.
#
# The image ships gcc (C++17 capable), cmake, make, curl, and git out of the
# box. Rust is NOT bundled, so we install it via rustup.
FROM quay.io/pypa/manylinux_2_28_x86_64

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal
ENV PATH=/root/.cargo/bin:$PATH

# control cc crate and cargo command
# target == host, so the image's default gcc/g++/ar cover both host build
# dependencies and the OCCT cmake build.
# ENV CC=gcc
# ENV CXX=g++
# ENV AR=ar
ENV CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu

# add cargo target
RUN rustup target add ${CARGO_BUILD_TARGET}

# copy source and build OCCT prebuilt
WORKDIR /src
COPY . /src
