|
| 1 | +# Copyright 2026-present Alibaba Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# CentOS 7 cross-build verification image for paimon-cpp + tantivy-fts. |
| 16 | +# |
| 17 | +# Purpose: |
| 18 | +# Prove the tantivy-fts stack builds on the OLDEST reasonable Linux target |
| 19 | +# (glibc 2.17, EOL 2024-06-30). The default Ubuntu 24.04 dev container |
| 20 | +# proves nothing about glibc compatibility; this image does. |
| 21 | +# |
| 22 | +# Build: |
| 23 | +# docker build -t paimon-cpp-centos7:latest -f .devcontainer/centos7/Dockerfile . |
| 24 | +# |
| 25 | +# Run: |
| 26 | +# docker run -d --name paimon-centos7 \ |
| 27 | +# --privileged \ |
| 28 | +# -v "$(pwd):/workspaces/paimon-cpp" \ |
| 29 | +# paimon-cpp-centos7:latest sleep infinity |
| 30 | +# docker exec -it paimon-centos7 bash -l |
| 31 | +# |
| 32 | +# Inside the container: |
| 33 | +# scl enable devtoolset-11 rh-python38 -- bash # activate modern gcc + python |
| 34 | +# source /opt/paimon-env.sh # PATH for rust, cmake |
| 35 | +# cd /workspaces/paimon-cpp |
| 36 | +# git lfs install --local && git lfs pull # critical: boost & friends are LFS |
| 37 | +# ./scripts/tantivy_smoke.sh |
| 38 | + |
| 39 | +# ---------- Base ---------- |
| 40 | +# CentOS 7 reached EOL 2024-06-30; its default mirrorlist.centos.org is down. |
| 41 | +# Pin to vault.centos.org (Red Hat's archived location) via the `linuxserver/centos` |
| 42 | +# vault image to avoid retired-mirror failures on `yum install`. |
| 43 | +# |
| 44 | +# Base image: we pull from quay.io (CentOS community's canonical registry post |
| 45 | +# Docker Hub deprecation). Override with CENTOS7_IMAGE build arg when behind a |
| 46 | +# firewall that can't reach quay.io (e.g. registry.aliyuncs.com/library/centos:7). |
| 47 | +ARG CENTOS7_IMAGE=quay.io/centos/centos:centos7 |
| 48 | +FROM ${CENTOS7_IMAGE} |
| 49 | + |
| 50 | +# Repoint yum at aliyun's CentOS 7 vault mirror — vault.centos.org itself |
| 51 | +# works but is slow/blocked from many CN networks; the aliyun mirror is a |
| 52 | +# complete rsync and reliably fast. We overwrite CentOS-Base.repo rather |
| 53 | +# than sed-patch it so the result is deterministic regardless of what the |
| 54 | +# upstream image ships. fastestmirror plugin is disabled because its ping |
| 55 | +# probes against the retired mirror list add ~60s to every `yum install`. |
| 56 | +RUN echo -e '[base]\n\ |
| 57 | +name=CentOS-7 - Base - aliyun vault\n\ |
| 58 | +baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/os/$basearch/\n\ |
| 59 | +gpgcheck=0\n\ |
| 60 | +enabled=1\n\ |
| 61 | +\n\ |
| 62 | +[updates]\n\ |
| 63 | +name=CentOS-7 - Updates - aliyun vault\n\ |
| 64 | +baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/updates/$basearch/\n\ |
| 65 | +gpgcheck=0\n\ |
| 66 | +enabled=1\n\ |
| 67 | +\n\ |
| 68 | +[extras]\n\ |
| 69 | +name=CentOS-7 - Extras - aliyun vault\n\ |
| 70 | +baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/extras/$basearch/\n\ |
| 71 | +gpgcheck=0\n\ |
| 72 | +enabled=1\n\ |
| 73 | +\n\ |
| 74 | +[centosplus]\n\ |
| 75 | +name=CentOS-7 - Plus - aliyun vault\n\ |
| 76 | +baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/centosplus/$basearch/\n\ |
| 77 | +gpgcheck=0\n\ |
| 78 | +enabled=0\n' > /etc/yum.repos.d/CentOS-Base.repo \ |
| 79 | + && rm -f /etc/yum.repos.d/CentOS-CR.repo \ |
| 80 | + /etc/yum.repos.d/CentOS-Debuginfo.repo \ |
| 81 | + /etc/yum.repos.d/CentOS-Media.repo \ |
| 82 | + /etc/yum.repos.d/CentOS-Sources.repo \ |
| 83 | + /etc/yum.repos.d/CentOS-Vault.repo \ |
| 84 | + /etc/yum.repos.d/CentOS-fasttrack.repo \ |
| 85 | + /etc/yum.repos.d/CentOS-x86_64-kernel.repo \ |
| 86 | + && if [ -f /etc/yum/pluginconf.d/fastestmirror.conf ]; then \ |
| 87 | + sed -i 's/^enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf; \ |
| 88 | + fi \ |
| 89 | + && yum clean all \ |
| 90 | + && yum makecache |
| 91 | + |
| 92 | +# ---------- Base toolchain ---------- |
| 93 | +# EPEL provides git-lfs, ninja-build, a newer python3 than the base 3.6. |
| 94 | +# SCL (Software Collections) provides devtoolset-11 (gcc 11) and rh-python38 |
| 95 | +# without overriding the system gcc/python. CentOS 7's default gcc 4.8 is |
| 96 | +# too old for C++17/20 used by lucene++ and our tantivy wrapper. |
| 97 | +# |
| 98 | +# Same story as CentOS-Base.repo: both epel + SCL default to mirrorlist |
| 99 | +# endpoints that are effectively dead; overwrite with aliyun URLs that we |
| 100 | +# know respond. |
| 101 | +RUN yum install -y epel-release centos-release-scl \ |
| 102 | + && echo -e '[epel]\n\ |
| 103 | +name=Extra Packages for Enterprise Linux 7 - aliyun\n\ |
| 104 | +baseurl=https://mirrors.aliyun.com/epel/7/$basearch\n\ |
| 105 | +gpgcheck=0\n\ |
| 106 | +enabled=1\n' > /etc/yum.repos.d/epel.repo \ |
| 107 | + && rm -f /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel.repo.rpmnew \ |
| 108 | + && rm -f /etc/yum.repos.d/CentOS-SCLo-*.repo \ |
| 109 | + /etc/yum.repos.d/CentOS-SCLo-*.repo.rpmnew \ |
| 110 | + && echo -e '[centos-sclo-rh]\n\ |
| 111 | +name=CentOS-7 - SCLo rh - aliyun vault\n\ |
| 112 | +baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/sclo/$basearch/rh/\n\ |
| 113 | +gpgcheck=0\n\ |
| 114 | +enabled=1\n\ |
| 115 | +\n\ |
| 116 | +[centos-sclo-sclo]\n\ |
| 117 | +name=CentOS-7 - SCLo sclo - aliyun vault\n\ |
| 118 | +baseurl=https://mirrors.aliyun.com/centos-vault/7.9.2009/sclo/$basearch/sclo/\n\ |
| 119 | +gpgcheck=0\n\ |
| 120 | +enabled=1\n' > /etc/yum.repos.d/CentOS-SCLo-scl.repo \ |
| 121 | + && yum clean all && yum makecache \ |
| 122 | + && yum install -y \ |
| 123 | + devtoolset-11-gcc \ |
| 124 | + devtoolset-11-gcc-c++ \ |
| 125 | + devtoolset-11-binutils \ |
| 126 | + devtoolset-11-libasan-devel \ |
| 127 | + devtoolset-11-libubsan-devel \ |
| 128 | + rh-python38 \ |
| 129 | + rh-python38-python-pip \ |
| 130 | + git \ |
| 131 | + git-lfs \ |
| 132 | + ninja-build \ |
| 133 | + make \ |
| 134 | + patch \ |
| 135 | + curl \ |
| 136 | + wget \ |
| 137 | + unzip \ |
| 138 | + which \ |
| 139 | + file \ |
| 140 | + sudo \ |
| 141 | + openssl-devel \ |
| 142 | + zlib-devel \ |
| 143 | + libffi-devel \ |
| 144 | + bzip2-devel \ |
| 145 | + xz-devel \ |
| 146 | + perl-IPC-Cmd \ |
| 147 | + && yum clean all |
| 148 | + |
| 149 | +# Enable the SCL collections for all subsequent shells (including RUN). |
| 150 | +ENV BASH_ENV=/etc/profile.d/scl-enable.sh |
| 151 | +SHELL ["/bin/bash", "-c"] |
| 152 | +RUN printf '%s\n' \ |
| 153 | + 'source scl_source enable devtoolset-11' \ |
| 154 | + 'source scl_source enable rh-python38' \ |
| 155 | + > /etc/profile.d/scl-enable.sh \ |
| 156 | + && chmod +x /etc/profile.d/scl-enable.sh |
| 157 | + |
| 158 | +# ---------- CMake (must be >= 3.22 for Corrosion) ---------- |
| 159 | +# CentOS 7's cmake package is 2.8.12; EPEL cmake3 is 3.17 — still too old. |
| 160 | +# Install via pip in the rh-python38 SCL so we get a modern CMake without |
| 161 | +# touching the system /usr/bin. Point pip at aliyun's pypi mirror: default |
| 162 | +# pypi.org is 10-30s per request from CN, aliyun responds in <1s. |
| 163 | +ENV PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ \ |
| 164 | + PIP_TRUSTED_HOST=mirrors.aliyun.com |
| 165 | +RUN source /etc/profile.d/scl-enable.sh \ |
| 166 | + && python3 -m pip install --upgrade pip \ |
| 167 | + && python3 -m pip install 'cmake==3.28.*' ninja |
| 168 | + |
| 169 | +# ---------- Rust toolchain ---------- |
| 170 | +# Install rustup as root into /opt/rust so all users share the same toolchain. |
| 171 | +# Use the USTC mirror to keep downloads fast in CN; the CI runner version of |
| 172 | +# this is mirrored in ci/scripts/setup_rust.sh. |
| 173 | +ENV RUSTUP_HOME=/opt/rust/rustup \ |
| 174 | + CARGO_HOME=/opt/rust/cargo \ |
| 175 | + RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static \ |
| 176 | + RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup |
| 177 | +# In-container network for Docker Desktop builds is unreliable through many |
| 178 | +# CN mirrors (observed: curl 7.29 on CentOS 7 + rsproxy.cn HTTP/2 path ⇒ |
| 179 | +# partial-read truncations; USTC ⇒ 5xx; rustup sh installer ⇒ 403 from |
| 180 | +# legacy cipher). The most reliable fix is to sidestep the issue entirely: |
| 181 | +# pre-download rustup-init on the host (where network is solid) and COPY it |
| 182 | +# into the image. See .devcontainer/centos7/run.sh for the prefetch step. |
| 183 | +COPY .devcontainer/centos7/rustup-init.bin /tmp/rustup-init |
| 184 | +RUN chmod +x /tmp/rustup-init \ |
| 185 | + && /tmp/rustup-init -y --default-toolchain stable --profile minimal --no-modify-path \ |
| 186 | + && rm -f /tmp/rustup-init \ |
| 187 | + && mkdir -p $CARGO_HOME \ |
| 188 | + && echo -e '[source.crates-io]\n\ |
| 189 | +replace-with = "rsproxy-sparse"\n\ |
| 190 | +\n\ |
| 191 | +[source.rsproxy]\n\ |
| 192 | +registry = "https://rsproxy.cn/crates.io-index"\n\ |
| 193 | +\n\ |
| 194 | +[source.rsproxy-sparse]\n\ |
| 195 | +registry = "sparse+https://rsproxy.cn/index/"\n\ |
| 196 | +\n\ |
| 197 | +[registries.rsproxy]\n\ |
| 198 | +index = "https://rsproxy.cn/crates.io-index"\n\ |
| 199 | +\n\ |
| 200 | +[net]\n\ |
| 201 | +git-fetch-with-cli = true\n' > $CARGO_HOME/config.toml \ |
| 202 | + && $CARGO_HOME/bin/cargo install cbindgen --version 0.29.2 --locked \ |
| 203 | + && chmod -R a+rwx /opt/rust \ |
| 204 | + && $CARGO_HOME/bin/rustc --version \ |
| 205 | + && $CARGO_HOME/bin/cargo --version \ |
| 206 | + && $CARGO_HOME/bin/cbindgen --version |
| 207 | + |
| 208 | +# ---------- Environment file consumed by every shell ---------- |
| 209 | +# Sets PATH for rust / cmake / cargo so `docker exec paimon-centos7 bash -l` |
| 210 | +# and interactive sessions have the toolchain on $PATH. |
| 211 | +RUN printf '%s\n' \ |
| 212 | + 'export PATH=/opt/rust/cargo/bin:$PATH' \ |
| 213 | + '# cmake + ninja live under the rh-python38 SCL; path prefix differs by arch.' \ |
| 214 | + '# `command -v cmake` confirms which one is in use.' \ |
| 215 | + > /opt/paimon-env.sh \ |
| 216 | + && chmod +x /opt/paimon-env.sh \ |
| 217 | + && printf '%s\n' 'source /opt/paimon-env.sh' >> /etc/profile.d/scl-enable.sh |
| 218 | + |
| 219 | +# ---------- Non-root user ---------- |
| 220 | +# Build as `paimon` (uid 1000) so LFS objects under the mount stay owned by |
| 221 | +# your host user, matching the main Ubuntu dev container. |
| 222 | +RUN useradd -m -u 1000 -s /bin/bash paimon \ |
| 223 | + && echo 'paimon ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/paimon |
| 224 | + |
| 225 | +USER paimon |
| 226 | +WORKDIR /workspaces/paimon-cpp |
| 227 | + |
| 228 | +# Sanity check surfaces the tool versions in `docker run ... paimon-cpp-centos7 --version`. |
| 229 | +CMD ["bash", "-lc", "\ |
| 230 | + echo '--- CentOS 7 cross-build image sanity check ---'; \ |
| 231 | + cat /etc/centos-release; \ |
| 232 | + echo '--- glibc ---'; ldd --version | head -1; \ |
| 233 | + echo '--- gcc ---'; gcc --version | head -1; \ |
| 234 | + echo '--- cmake ---'; cmake --version | head -1; \ |
| 235 | + echo '--- ninja ---'; ninja --version; \ |
| 236 | + echo '--- rust ---'; rustc --version; \ |
| 237 | + echo '--- cargo ---'; cargo --version; \ |
| 238 | + echo '--- cbindgen ---'; cbindgen --version; \ |
| 239 | + echo 'Ready. Mount paimon-cpp at /workspaces/paimon-cpp and run ./scripts/tantivy_smoke.sh'"] |
0 commit comments