-
Notifications
You must be signed in to change notification settings - Fork 80
feat: Add support for custom Docker image in create command #331
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
base: develop
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This pull request adds support for specifying custom Docker images for Frappe services, enhances the Docker build process with a new local build script, and improves prebaked app detection and handling. The changes enable users to override the default Frappe Docker image while maintaining compatibility with the existing build and configuration workflows.
- Added
frappe_imageparameter to CLI, configuration model, and compose generation logic - Introduced
build-local.shscript for automated local Docker image builds with configurable parameters - Improved prebaked app detection by reading
/prebake_infofile from containers to skip redundant installations
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| frappe_manager/commands.py | Added CLI option for custom frappe Docker image |
| frappe_manager/site_manager/bench_config.py | Added frappe_image field to config model and image parsing logic for compose inputs |
| frappe_manager/site_manager/site.py | Added support for applying custom images to compose configuration and fixed prebake image reference |
| frappe_manager/site_manager/workers_manager/SiteWorker.py | Added logic to apply custom frappe image to worker services |
| frappe_manager/site_manager/bench_operations.py | Added method to read prebaked apps from container's /prebake_info file |
| frappe_manager/site_manager/site_exceptions.py | Refactored branch change exception to inherit from correct base class with enhanced output control |
| Docker/frappe/Dockerfile | Updated pyenv and nvm versions; simplified prebake copying to include entire frappe-bench directory |
| Docker/frappe/helper-function.sh | Improved app name extraction regex to handle whitespace variations |
| Docker/build-local.sh | New script for building Docker images locally with architecture detection and configurable build arguments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if self.frappe_image: | ||
| # Parse image name and tag | ||
| if ":" in self.frappe_image: | ||
| image_name, image_tag = self.frappe_image.split(":", 1) |
Copilot
AI
Jan 5, 2026
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.
The image parsing logic here assumes that image names can only contain one colon. However, Docker images can have registry addresses (e.g., registry.example.com:5000/frappe-manager-local-frappe:v0.18.0), which would cause this code to incorrectly split the image. Consider using rsplit(":", 1) instead to split only on the last colon, or better yet, use a more robust image parsing approach.
| image_name, image_tag = self.frappe_image.split(":", 1) | |
| # Use rsplit to split on the last colon so registry ports are handled correctly | |
| image_name, image_tag = self.frappe_image.rsplit(":", 1) |
Docker/build-local.sh
Outdated
| IMAGE_TAG=$(jq -rc ".${image}" images-tag.json || exit 0) | ||
|
|
||
| if [[ "${IMAGE_TAG:-}" ]]; then | ||
| CONTEXT_DIR="${image}/." |
Copilot
AI
Jan 5, 2026
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.
The build script assumes it will be executed from the Docker directory (since it references images-tag.json and ${image}/. as context paths without any directory prefix). However, there's no documentation or check to ensure the script is run from the correct directory. Consider adding a check at the beginning of the script to verify the working directory or use absolute paths based on the script's location.
|
|
||
| frappe_image: str = self.compose_project.compose_file_manager.yml["services"]["frappe"]["image"] | ||
| frappe_image = frappe_image.replace('-frappe', '-prebake') | ||
| workspace_copy_image = frappe_image.replace('-frappe', '-prebake') |
Copilot
AI
Jan 5, 2026
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.
The variable workspace_copy_image is renamed from frappe_image but the logic still attempts to derive the prebake image by replacing '-frappe' with '-prebake'. If a user provides a custom frappe image that doesn't follow the naming convention (e.g., doesn't contain '-frappe' in the name), this replacement will silently fail to produce the expected prebake image name. Consider adding validation or documentation about the expected image naming convention.
| workspace_copy_image = frappe_image.replace('-frappe', '-prebake') | |
| if "-frappe" not in frappe_image: | |
| raise BenchException( | |
| f"Unable to derive workspace prebake image from frappe image '{frappe_image}'. " | |
| "Expected the image name to contain '-frappe' so it can be replaced with '-prebake'." | |
| ) | |
| workspace_copy_image = frappe_image.replace("-frappe", "-prebake") |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Nice @asaura08 are you one of the maintainers this repo? |
|
This pull request introduces support for specifying a custom Docker image for the Frappe service, along with improvements to the Docker build process and better handling of prebaked app detection. The changes allow users to pass a custom image for Frappe and related services, streamline Docker image building, and improve robustness in app installation and configuration.
Custom Docker image support:
frappe_imageparameter to the command-line interface, configuration model (BenchConfig), and TOML export, enabling users to specify a custom Docker image for the Frappe service. This image is propagated to all relevant services in the Docker Compose configuration and worker setup. [1] [2] [3] [4] [5] [6] [7]Examples:
Create a new custom image
PYTHON_VERSIONS=3.14.2 NODE_VERSIONS=24 PREBAKE_APPS='erpnext:version-16-beta,builder:develop' PREBAKE_FRAPPE_BRANCH=version-16-beta ./build-local.sh --no-cacheUse the new custom image
Docker build process improvements:
Docker/build-local.shscript to automate local Docker image builds with configurable arguments and architecture detection, supporting prebaked images and custom build parameters.Docker/frappe/Dockerfileto use newer versions ofpyenvandnvm, and simplified prebake logic by copying the entirefrappe-benchdirectory instead of individual apps. [1] [2]Prebaked app handling and robustness:
/prebake_infofile inside the container, ensuring that only non-prebaked apps are installed during setup. [1] [2]Other improvements:
hooks.pyto be more robust against formatting variations.Notes:
This PR closes #330 #329
This PR resolves #323 #332