feat(dockerfiles): add Python 3.12 and pip to base Docker image#4760
Conversation
There was a problem hiding this comment.
I have already done a preliminary review for you, and I hope to help you do a better job.
Summary
This PR updates the base Dockerfile used in CI to add Python 3.12 and its pip package manager, alongside existing Python 2 and Python 3. The approach is straightforward: the Dockerfile’s dnf install command now includes python3.12 and python3.12-pip. However, the symbolic links and pip install commands still point to Python 2 versions, which likely causes inconsistency. Overall, the change partially achieves the goal but misses aligning the Python and pip symlinks and usage to the newly added Python 3.12.
Critical Issues
-
Outdated python and pip symlinks (dockerfiles/ci/base/Dockerfile, lines ~14-16):
The symlinks still point to Python 2 executables:ln -s /usr/bin/python2 /usr/bin/python && \ ln -s /usr/bin/pip2 /usr/bin/pip && \
This conflicts with the intention to use Python 3.12. Using Python 2 as default can cause environment inconsistency and break Python 3.12 packages.
Suggested fix:
Update the symlinks to point to Python 3.12 and pip3.12:ln -s /usr/bin/python3.12 /usr/bin/python && \ ln -s /usr/bin/pip3.12 /usr/bin/pip && \
-
pip installusing pip2 instead of pip3 (dockerfiles/ci/base/Dockerfile, line ~17):
The current command:pip install s3cmd==2.3.0 requests==2.26.0 certifi==2021.10.8
implicitly uses
/usr/bin/pipwhich currently points to pip2, installing packages into Python 2 environment, which is likely unintended.Suggested fix:
After fixing the symlink, this command will run correctly under pip3.12. Alternatively, explicitly usepip3.12:pip3.12 install s3cmd==2.3.0 requests==2.26.0 certifi==2021.10.8
Code Improvements
-
Verify Python version fallback handling:
If the image must support multiple Python versions, consider explicitly defining alternatives usingupdate-alternativesrather than static symlinks, which will improve flexibility:alternatives --install /usr/bin/python python /usr/bin/python3.12 1 alternatives --install /usr/bin/pip pip /usr/bin/pip3.12 1
This approach makes switching between Python versions cleaner and more maintainable.
-
Add explicit
python3symlink if needed:
Ensure/usr/bin/python3points to Python 3.12 if scripts rely onpython3command.
Best Practices
-
Add comments explaining Python version selection:
Add a brief comment about why Python 3.12 is installed alongside Python 2 and the default Python version choice. This aids future maintainers. -
Testing:
Ensure the Docker image is tested for Python version correctness and installed packages. It would be helpful to add a simple RUN test in the Dockerfile to verify:RUN python --version && pip --version
Summary of key actionables:
- Change symlinks for
/usr/bin/pythonand/usr/bin/pipto point to python3.12 and pip3.12 respectively. - Update or explicitly invoke pip3.12 for package installations.
- Consider using alternatives system for better version management.
- Add comments and simple validation steps in Dockerfile.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wuhuizuo The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…rt (#4762) ## Summary Update all ticdc pod templates to use the new Jenkins image with Python 3.12 support (from PR #4760). ## Changes Update image tag from `v2025.12.28-2-g97bb688-go1.25` to `v2026.6.28-3-g80620cc5-go1.25` in: - `pipelines/pingcap/ticdc/` (52 files) - `pipelines/pingcap-inc/ticdc/` (14 files) Total: **66 files** ## Testing - Verify CI pipelines use the new image tag - Verify ticdc integration tests pass with Python 3.12 - Verify `tomllib` import works in CI environment ## Risk Low. This is a tag-only update to use the already-built image from PR #4760. The new image includes Python 3.12 while maintaining backward compatibility with existing tools. Ref: FLA-231 Depends on: #4760 Signed-off-by: wuhuizuo <wuhuizuo@126.com>
## Summary Fix Python 3.6 override issue: both the Rocky Linux 8 base image and the nsolid (Node.js) installation pull in `python3` (3.6), making `python3` default to 3.6 despite 3.12 being installed. ## Changes - Add `ln -sf /usr/bin/python3.12 /usr/local/bin/python3` — `python3` now resolves to 3.12 via higher PATH priority - Add `ln -sf /usr/bin/pip3.12 /usr/local/bin/pip3` — `pip3` now uses Python 3.12's pip ## Root Cause 1. Base image `quay.io/rockylinux/rockylinux:8.10` ships `python3` (3.6) pre-installed 2. `nsolid` RPM (Node.js) installation pulls in `python36` AppStream module 3. `python3.12` only provides `/usr/bin/python3.12`, not `/usr/bin/python3` ## Testing After rebuild, verify: ``` python3 --version # → Python 3.12.x pip3 --version # → pip 24.x from Python 3.12 python3 -c "import tomllib" # → no error ``` ## Risk Low. The symlinks are in `/usr/local/bin` which has PATH priority over `/usr/bin`. Existing `python27`/`pip2` symlinks in `/usr/bin` are unaffected. RPM-installed `python3` (3.6) is still present but no longer the default. Ref: FLA-231 Related: #4760, #4762 --------- Signed-off-by: wuhuizuo <wuhuizuo@126.com>
…7eaa-go1.25 (#4767) ## Summary Update all ticdc pod templates to use the new Jenkins image tag that includes the Python 3.12 symlink fix. ## Changes Update image tag from `v2026.6.28-3-g80620cc5-go1.25` → `v2026.6.28-8-g92327eaa-go1.25` in: - `pipelines/pingcap/ticdc/` (52 files) - `pipelines/pingcap-inc/ticdc/` (14 files) Total: **66 files** ## Testing - Verify CI pipelines use the new image tag - Verify `python3 --version` returns Python 3.12.x - Verify ticdc integration tests pass ## Risk Low. Pure tag update. The new image includes both Python 3.12 (PR #4760) and the symlink fix ensuring `python3`/`pip3` resolve to 3.12 (PR #4766). --------- Signed-off-by: wuhuizuo <wuhuizuo@126.com>
No description provided.