[PR #7] [MERGED] feat: Add Docker default image configuration support #115

Closed
opened 2026-06-06 22:09:15 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/7
Author: @asdek
Created: 2/1/2025
Status: Merged
Merged: 2/1/2025
Merged by: @asdek

Base: masterHead: 5-issue-with-correct-choose-docker-image


📝 Commits (2)

  • 26ec423 feat: Add Docker default image configuration support
  • fe378a9 fix: normalize Docker image name to lowercase

📊 Changes

7 files changed (+84 additions, -17 deletions)

View changed files

📝 .env.example (+1 -0)
📝 Dockerfile (+9 -0)
📝 backend/pkg/config/config.go (+6 -5)
📝 backend/pkg/docker/client.go (+61 -7)
📝 backend/pkg/providers/providers.go (+3 -2)
📝 backend/pkg/templates/prompts/image_chooser.tmpl (+3 -3)
📝 docker-compose.yml (+1 -0)

📄 Description

Changelog

  • Updated .env.example to include DOCKER_DEFAULT_IMAGE configuration
  • Modified docker-compose.yml to pass default image environment variable
  • Enhanced Dockerfile with additional build essentials
  • Updated backend configuration and Docker client to support configurable default image
  • Updated image chooser template to use dynamic default image
  • Improved error handling and fallback mechanisms for Docker image selection
  • Normalize incoming Docker image name to lowercase and trim spaces

Problem

When users attempt to create flow workers without specifying a valid Docker image, they encounter errors due to invalid or improperly formatted image names. This often results in container creation failures with error messages like:

Docker error: invalid reference format: repository name must be lowercase, failed to spawn container 'pentagi-terminal-4': failed to create container: Error response from daemon: invalid reference format

This issue arises because the AI model may generate an incorrect or non-lowercase Docker image name, leading to failures in container instantiation. It affects the user experience by interrupting workflows and requiring manual intervention to correct image names.

Solution

This change introduces a configurable default Docker image through the DOCKER_DEFAULT_IMAGE environment variable. Key aspects of the solution include:

  • Configuration Option: Added DOCKER_DEFAULT_IMAGE to .env.example and updated docker-compose.yml to pass this environment variable to the backend service.
  • Backend Support: Modified the backend configuration and Docker client to utilize the default image when the specified image is invalid or not provided.
  • Template Update: Updated the image chooser template to incorporate the dynamic default image, guiding the AI model to select the correct image more effectively.
  • Error Handling: Enhanced error handling mechanisms to validate image names, enforce lowercase formatting, and provide clearer error messages. Implemented fallback logic to use the default image when the provided image is invalid.

These changes improve robustness in container creation, reduce errors related to image selection, and enhance the overall user experience by providing sensible defaults and better guidance.

Partially closes #5

Type of Change

  • 🚀 New feature (non-breaking change which adds functionality)
  • 🔧 Configuration change
  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🧪 Test update
  • 🛡️ Security update

Test Steps

  1. Set DOCKER_DEFAULT_IMAGE=alpine:latest in the .env file.
  2. Rebuild and restart the services using docker-compose up --build.
  3. Initiate a flow worker creation without specifying a Docker image.
  4. Verify that the system uses the default alpine:latest image and the container is created successfully.
  5. Deliberately provide an invalid image name to test error handling.
  6. Check that the system falls back to the default image and logs appropriate warnings.
  7. Review logs and system behavior for any anomalies.

Test Results

  • The flow worker was created successfully using the default image when no image was specified.
  • When an invalid image name was provided, the system defaulted to alpine:latest without crashing.
  • Error messages were clear, and logs indicated the use of the default image.
  • No unexpected errors or issues were observed during testing.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/7 **Author:** [@asdek](https://github.com/asdek) **Created:** 2/1/2025 **Status:** ✅ Merged **Merged:** 2/1/2025 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `master` ← **Head:** `5-issue-with-correct-choose-docker-image` --- ### 📝 Commits (2) - [`26ec423`](https://github.com/vxcontrol/pentagi/commit/26ec423f950a7fa123d80e50e0a5bf0a4b51e209) feat: Add Docker default image configuration support - [`fe378a9`](https://github.com/vxcontrol/pentagi/commit/fe378a94038f1c299d12e3b1b571fa23108cd78d) fix: normalize Docker image name to lowercase ### 📊 Changes **7 files changed** (+84 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+1 -0) 📝 `Dockerfile` (+9 -0) 📝 `backend/pkg/config/config.go` (+6 -5) 📝 `backend/pkg/docker/client.go` (+61 -7) 📝 `backend/pkg/providers/providers.go` (+3 -2) 📝 `backend/pkg/templates/prompts/image_chooser.tmpl` (+3 -3) 📝 `docker-compose.yml` (+1 -0) </details> ### 📄 Description ### Changelog - Updated `.env.example` to include `DOCKER_DEFAULT_IMAGE` configuration - Modified `docker-compose.yml` to pass default image environment variable - Enhanced `Dockerfile` with additional build essentials - Updated backend configuration and Docker client to support configurable default image - Updated image chooser template to use dynamic default image - Improved error handling and fallback mechanisms for Docker image selection - Normalize incoming Docker image name to lowercase and trim spaces ### Problem When users attempt to create flow workers without specifying a valid Docker image, they encounter errors due to invalid or improperly formatted image names. This often results in container creation failures with error messages like: ``` Docker error: invalid reference format: repository name must be lowercase, failed to spawn container 'pentagi-terminal-4': failed to create container: Error response from daemon: invalid reference format ``` This issue arises because the AI model may generate an incorrect or non-lowercase Docker image name, leading to failures in container instantiation. It affects the user experience by interrupting workflows and requiring manual intervention to correct image names. ### Solution This change introduces a configurable default Docker image through the `DOCKER_DEFAULT_IMAGE` environment variable. Key aspects of the solution include: - **Configuration Option**: Added `DOCKER_DEFAULT_IMAGE` to `.env.example` and updated `docker-compose.yml` to pass this environment variable to the backend service. - **Backend Support**: Modified the backend configuration and Docker client to utilize the default image when the specified image is invalid or not provided. - **Template Update**: Updated the image chooser template to incorporate the dynamic default image, guiding the AI model to select the correct image more effectively. - **Error Handling**: Enhanced error handling mechanisms to validate image names, enforce lowercase formatting, and provide clearer error messages. Implemented fallback logic to use the default image when the provided image is invalid. These changes improve robustness in container creation, reduce errors related to image selection, and enhance the overall user experience by providing sensible defaults and better guidance. <!-- Enter any applicable Issue number(s) here that will be closed/resolved by this PR. --> Partially closes #5 ### Type of Change <!-- Mark with an `x` all options that apply --> - [x] 🚀 New feature (non-breaking change which adds functionality) - [x] 🔧 Configuration change - [ ] 🐛 Bug fix (non-breaking change which fixes an issue) - [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 📚 Documentation update - [ ] 🧪 Test update - [ ] 🛡️ Security update ### Test Steps 1. Set `DOCKER_DEFAULT_IMAGE=alpine:latest` in the `.env` file. 2. Rebuild and restart the services using `docker-compose up --build`. 3. Initiate a flow worker creation without specifying a Docker image. 4. Verify that the system uses the default `alpine:latest` image and the container is created successfully. 5. Deliberately provide an invalid image name to test error handling. 6. Check that the system falls back to the default image and logs appropriate warnings. 7. Review logs and system behavior for any anomalies. ### Test Results - The flow worker was created successfully using the default image when no image was specified. - When an invalid image name was provided, the system defaulted to `alpine:latest` without crashing. - Error messages were clear, and logs indicated the use of the default image. - No unexpected errors or issues were observed during testing. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:15 -04:00
yindo closed this issue 2026-06-06 22:09:15 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#115