Skip to content

fix(docker): use python:3.11-slim base for >=3.9 requirement - #345

Merged
wanghan-iapcm merged 3 commits into
deepmodeling:masterfrom
wanghan-iapcm:fix-docker-py39-base
Jun 8, 2026
Merged

wanghan-iapcm merged 3 commits into
deepmodeling:masterfrom
wanghan-iapcm:fix-docker-py39-base

Conversation

@wanghan-iapcm

@wanghan-iapcm wanghan-iapcm commented Jun 8, 2026 •

Copy link
Copy Markdown

Problem

The Publish Docker image workflow (.github/workflows/pub-docker.yml) fails on master after the minimum-Python bump to 3.9:

ERROR: Package 'dpgen2' requires a different Python: 3.8.20 not in '>=3.9'

The Dockerfile base dptechnology/dflow:latest ships Python 3.8.20, while pyproject.toml now declares requires-python = ">=3.9", so pip install . aborts.

Why it wasn't caught pre-merge

pub-docker.yml only triggers on push: master / release (no pull_request), and the unit-test workflow provisions Python via actions/setup-python rather than the Dockerfile — so nothing builds the image on PRs. The breakage only surfaces on the post-merge push to master.

Fix

  1. Dockerfile — switch the base image to python:3.11-slim.

    • pydflow is a declared dependency of dpgen2, so it is installed by pip install . and need not be baked into the base image (the old dflow base was effectively "python 3.8 + pydflow").
    • All install-time dependencies ship cp311 manylinux wheels, so no source compilation is needed and the slim image is sufficient.
    • deepmd-kit is not a dpgen2 dependency and is never installed/built in this image; deepmd runs in separate task containers, so its C++/CMake build is unaffected by this base-image choice.
  2. .github/workflows/test-docker.yml (new) — a build-only (push: false) workflow that builds the Dockerfile on pull requests touching Dockerfile / pyproject.toml. It requires no registry login or secrets, so it also works for fork PRs, and it closes the gap that let this breakage reach master unnoticed.

Validation

The new build-only workflow runs on this PR (it touches both Dockerfile and the workflow file), so the base-image fix is validated here before merge.

The Publish Docker image workflow broke on master after the minimum
Python bump to 3.9: the base image dptechnology/dflow:latest ships
Python 3.8.20, so `pip install .` aborts with "Package 'dpgen2'
requires a different Python: 3.8.20 not in '>=3.9'".

Switch the base to python:3.11-slim. pydflow is a declared dependency
of dpgen2, so it is installed by `pip install .` and need not be baked
into the base image. All install-time dependencies ship manylinux
wheels (no source build), so the slim image is sufficient.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jun 8, 2026
@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@wanghan-iapcm, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 23 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7e9cb3a-023e-44c4-af39-d9d7a7a09877

📥 Commits

Reviewing files that changed from the base of the PR and between f9da91c and a111b7f.

📒 Files selected for processing (2)
  • .github/workflows/test-docker.yml
  • Dockerfile
📝 Walkthrough

Walkthrough

The Dockerfile's base image is updated from the custom deep flow container (dptechnology/dflow:latest) to the standard Python 3.11 slim image (python:3.11-slim). The remaining build steps for working directory, context copying, and dependency installation remain unchanged.

Changes

Container Base Image Update

Layer / File(s) Summary
Base image specification
Dockerfile
The FROM instruction switches from dptechnology/dflow:latest to python:3.11-slim, replacing a custom container with the standard Python 3.11-slim distribution.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested labels

dependencies, size:S

Suggested reviewers

  • zjgemi
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: replacing the Docker base image to use python:3.11-slim to satisfy the project's >=3.9 Python requirement, which directly addresses the problem identified in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Dockerfile (1)

1-5: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Run the image as a non-root user before publish

Line 1–5 builds a published image that defaults to root because no USER is set. Given .github/workflows/pub-docker.yml pushes this image, this weakens runtime isolation unnecessarily.

Proposed hardening patch
 FROM python:3.11-slim
 
 WORKDIR /data/dpgen2
 COPY ./ ./
 RUN pip install --no-cache-dir .
+RUN useradd --create-home --uid 10001 appuser && chown -R appuser:appuser /data/dpgen2
+USER appuser
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` around lines 1 - 5, The Dockerfile currently runs as root; add a
non-root user and switch to it before publishing: create a dedicated user and
group (e.g., appuser), ensure ownership of WORKDIR (/data/dpgen2) and any
installed files is changed to that user (use RUN to addgroup/adduser and chown
the WORKDIR after COPY and pip install), then set USER to that non-root user at
the end of the Dockerfile so subsequent containers run unprivileged; reference
the existing WORKDIR, COPY, RUN pip install, and add a final USER instruction to
apply this change.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@Dockerfile`:
- Around line 1-5: The Dockerfile currently runs as root; add a non-root user
and switch to it before publishing: create a dedicated user and group (e.g.,
appuser), ensure ownership of WORKDIR (/data/dpgen2) and any installed files is
changed to that user (use RUN to addgroup/adduser and chown the WORKDIR after
COPY and pip install), then set USER to that non-root user at the end of the
Dockerfile so subsequent containers run unprivileged; reference the existing
WORKDIR, COPY, RUN pip install, and add a final USER instruction to apply this
change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8e80220b-6bf8-4a8d-b881-3a54dc593195

📥 Commits

Reviewing files that changed from the base of the PR and between ed23df2 and f9da91c.

📒 Files selected for processing (1)
  • Dockerfile

@wanghan-iapcm
wanghan-iapcm requested review from njzjz and zjgemi June 8, 2026 12:21
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 8, 2026
Han Wang added 2 commits June 8, 2026 20:26
Add a build-only (push: false) workflow that builds the Dockerfile on
pull requests touching Dockerfile / pyproject.toml. The existing
Publish Docker image workflow only runs on push to master and on
release, so base-image problems (such as the recent Python 3.8 vs
>=3.9 mismatch) were only discovered after merge. This job requires no
registry login or secrets, so it also works for fork pull requests.
python:3.11-slim has no git, but the build backend (setuptools_scm)
shells out to git to derive the version from the repository, so
`pip install .` failed at "Getting requirements to build wheel". Install
git in the image before the build. The old dflow base happened to carry
git, which masked this requirement.
@codecov

codecov Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.19%. Comparing base (ed23df2) to head (a111b7f).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #345   +/-   ##
=======================================
  Coverage   84.19%   84.19%           
=======================================
  Files         104      104           
  Lines        6107     6107           
=======================================
  Hits         5142     5142           
  Misses        965      965           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wanghan-iapcm
wanghan-iapcm merged commit 1383eb7 into deepmodeling:master Jun 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants