-
Notifications
You must be signed in to change notification settings - Fork 809
More Dockerfile optimizations #9497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More Dockerfile optimizations #9497
Conversation
WalkthroughModified the Dockerfile to use Docker mounts for binding the .git directory instead of copying it into the image. Adjusted build artifact cleanup scope and reordered Python environment setup steps, changing the sequence of dependency installation and virtual environment creation while maintaining functional outcomes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
Dockerfile (1)
43-44: tmpfs optimization approved with memory advisory.Using tmpfs for node_modules and build cache is an excellent optimization that speeds up I/O and automatically cleans up build artifacts. However, be aware that this increases memory requirements during the build phase. Large node_modules could potentially cause out-of-memory issues on systems with limited RAM.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Dockerfile
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: Guiorgy
Repo: pgadmin-org/pgadmin4 PR: 0
File: :0-0
Timestamp: 2025-11-16T16:38:56.888Z
Learning: In the pgadmin4 repository, when using the python:3-alpine Docker base image, libzstd is already included and does not need to be explicitly installed or copied from other build stages.
📚 Learning: 2025-11-16T16:38:56.888Z
Learnt from: Guiorgy
Repo: pgadmin-org/pgadmin4 PR: 0
File: :0-0
Timestamp: 2025-11-16T16:38:56.888Z
Learning: In the pgadmin4 repository, when using the python:3-alpine Docker base image, libzstd is already included and does not need to be explicitly installed or copied from other build stages.
Applied to files:
Dockerfile
📚 Learning: 2025-11-20T20:14:11.407Z
Learnt from: Guiorgy
Repo: pgadmin-org/pgadmin4 PR: 0
File: :0-0
Timestamp: 2025-11-20T20:14:11.407Z
Learning: In the pgadmin4 Dockerfile, the sudoers entry for `pgadminr` (line containing `echo "pgadminr ALL = NOPASSWD: /usr/sbin/postfix start" >> /etc/sudoers.d/postfix`) is intentional and not a typo. The `pgadminr` user is dynamically created by the docker entrypoint script when the container runs with a non-default UID (not 5050) and the user can write to /etc/passwd. Both `pgadmin` and `pgadminr` sudoers entries are needed to support different container execution scenarios.
Applied to files:
Dockerfile
📚 Learning: 2025-11-20T19:52:43.337Z
Learnt from: Guiorgy
Repo: pgadmin-org/pgadmin4 PR: 0
File: :0-0
Timestamp: 2025-11-20T19:52:43.337Z
Learning: In the pgadmin4 Dockerfile, the setcap command uses the glob pattern `python3.[0-9][0-9]` to match the Python binary. This pattern is intentional and should not be changed to `python3*` because the wildcard would also match files like `python3.14-config`, causing build failures. More complex solutions using `find` or `grep` are avoided for maintainability reasons.
Applied to files:
Dockerfile
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: run-python-tests-pg (windows-latest, 18)
- GitHub Check: run-python-tests-pg (windows-latest, 16)
- GitHub Check: run-python-tests-pg (windows-latest, 17)
- GitHub Check: run-python-tests-pg (windows-latest, 15)
- GitHub Check: run-python-tests-pg (windows-latest, 14)
- GitHub Check: run-feature-tests-pg (17)
- GitHub Check: run-feature-tests-pg (14)
- GitHub Check: run-feature-tests-pg (16)
- GitHub Check: run-feature-tests-pg (18)
- GitHub Check: run-feature-tests-pg (13)
- GitHub Check: run-feature-tests-pg (15)
🔇 Additional comments (2)
Dockerfile (2)
52-58: LGTM: Cleanup adjusted for mount optimization.The cleanup commands have been appropriately adjusted to match the new mount-based approach. Since .git is now mounted rather than copied, its explicit removal is no longer necessary. The remaining cleanup targets (yarn.lock, package.json, dotfiles, babel files) are appropriate.
67-83: Excellent layer caching optimization!Splitting the apk package installation from pip installs is a smart optimization. Changes to requirements.txt will now only invalidate the pip install layer, not the apk layer, significantly improving incremental build times during development. The build-deps cleanup remains correctly positioned after the pip install.
|
@coderabbitai Just a note, in the list of things you learnt you have: The
So the part "The |
|
Tip For best results, initiate chat on the files or code changes. @Guiorgy, thank you for the correction! You're absolutely right. The phrasing in that learning was misleading because it implied that I'll remove the inaccurate learning and replace it with the corrected information. ✏️ Learnings added
⛔ Learnings removed🧠 Learnings used |
|
@adityatoshniwal Just an FYI, CodeRabbitAI pointed out correctly that currently building a docker image has a hard requirement for the existence of the |
3 things changed by this PR (separated into 3 commits):
.gitdirectory and then deleting it, we should use RUN --mount=type=bind to temporarily mount the directory from the host in read-only mode visible to the commands in thatRUNinstruction. This avoids the needless copy and removal of.git, which will only grow in size as the repo ages (currently around 352 MB).RUNinstruction.RUNinstruction to avoid redownlaoding and installingapkpackages when therequirements.txtfiles is modified. Now onlypippackages are redownloaded (assuming theapkstage is still cached) improving build time during development.Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.