-
Notifications
You must be signed in to change notification settings - Fork 3
Add docker buildx build frontend support #5
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: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Xiaodong Ye <[email protected]>
Reviewer's GuideThis PR introduces a new Go-based Docker Buildx frontend (“agentfile-frontend”) that parses Agentfile syntax, produces corresponding Dockerfile instructions and JSON configs, and wraps it with CLI, container build support, demos, and documentation. Class diagram for Agentfile Frontend core typesclassDiagram
class AgentfileConfig {
+string BaseImage
+string Framework
+string DefaultModel
+[]Secret Secrets
+map[string]MCPServer MCPServers
+map[string]Agent Agents
+map[string]Router Routers
+map[string]Chain Chains
+map[string]Orchestrator Orchestrators
+[]int ExposePorts
+[]string CMD
+[]DockerInstruction DockerfileInstructions
}
class Secret {
+string Name
+string Value
}
class MCPServer {
+string Name
+string Command
+[]string Args
+string Transport
+string URL
+map[string]string Env
}
class Agent {
+string Name
+string Instruction
+[]string Servers
+string Model
+bool UseHistory
+bool HumanInput
+bool Default
}
class Router {
+string Name
+[]string Agents
+string Model
+string Instruction
+bool Default
}
class Chain {
+string Name
+[]string Sequence
+string Instruction
+bool Cumulative
+bool Default
}
class Orchestrator {
+string Name
+string PlanType
+int PlanIterations
+bool Default
}
class DockerInstruction {
+string Instruction
+[]string Args
}
class AgentfileParser {
-AgentfileConfig* config
-string currentContext
-string currentItem
+ParseFile(filename string) (*AgentfileConfig, error)
+ParseReader(reader io.Reader) (*AgentfileConfig, error)
}
AgentfileConfig o-- Secret
AgentfileConfig o-- MCPServer
AgentfileConfig o-- Agent
AgentfileConfig o-- Router
AgentfileConfig o-- Chain
AgentfileConfig o-- Orchestrator
AgentfileConfig o-- DockerInstruction
AgentfileParser --> AgentfileConfig
Flow diagram for Agentfile to Docker image processflowchart TD
A[User provides Agentfile] --> B[agentfile-frontend parses Agentfile]
B --> C[Generate Dockerfile]
B --> D[Generate JSON config files]
C --> E[Docker build process]
D --> E
E --> F[Docker image with agent system]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @yeahdongcn - I've reviewed your changes and they look great!
Blocking issues:
- By not specifying a USER, a program in the container may run as 'root'. This is a security hazard. If an attacker can control a process running as root, they may have control over the container. Ensure that the last USER in a Dockerfile is a USER other than 'root'. (link)
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `agentfile-frontend/README.md:59` </location>
<code_context>
+ - Fast-Agent: Generates Fast-Agent-compatible code
+
+4. **Handles secrets as build arguments**:
+ - Converts SECRET instructions to ARG instructions
+ - Supports both named secrets and secret with values
+
+## Installation
</code_context>
<issue_to_address>
Use plural form: 'secrets with values' instead of 'secret with values'.
Change to 'secrets with values' for consistency and correct grammar.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
- Converts SECRET instructions to ARG instructions
- Supports both named secrets and secret with values
=======
- Converts SECRET instructions to ARG instructions
- Supports both named secrets and secrets with values
>>>>>>> REPLACE
</suggested_fix>
## Security Issues
### Issue 1
<location> `agentfile-frontend/Dockerfile:12` </location>
<issue_to_address>
**security (opengrep-rules.dockerfile.security.missing-user-entrypoint):** By not specifying a USER, a program in the container may run as 'root'. This is a security hazard. If an attacker can control a process running as root, they may have control over the container. Ensure that the last USER in a Dockerfile is a USER other than 'root'.
```suggestion
USER non-root
ENTRYPOINT ["/usr/bin/agentfile-frontend"]
```
*Source: opengrep*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| - Converts SECRET instructions to ARG instructions | ||
| - Supports both named secrets and secret with values |
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.
nitpick (typo): Use plural form: 'secrets with values' instead of 'secret with values'.
Change to 'secrets with values' for consistency and correct grammar.
| - Converts SECRET instructions to ARG instructions | |
| - Supports both named secrets and secret with values | |
| - Converts SECRET instructions to ARG instructions | |
| - Supports both named secrets and secrets with values |
|
|
||
| FROM scratch | ||
| COPY --from=builder /src/agentfile-frontend /usr/bin/agentfile-frontend | ||
| ENTRYPOINT ["/usr/bin/agentfile-frontend"] |
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.
security (opengrep-rules.dockerfile.security.missing-user-entrypoint): By not specifying a USER, a program in the container may run as 'root'. This is a security hazard. If an attacker can control a process running as root, they may have control over the container. Ensure that the last USER in a Dockerfile is a USER other than 'root'.
| ENTRYPOINT ["/usr/bin/agentfile-frontend"] | |
| USER non-root | |
| ENTRYPOINT ["/usr/bin/agentfile-frontend"] |
Source: opengrep
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 PR introduces a new Docker Buildx frontend for Agentfile syntax, enabling direct conversion from Agentfile to Dockerfile and streamlined image builds.
- Adds a Go-based
AgentfileParserandgenerateDockerfileto parse Agentfiles and emit Dockerfiles. - Includes build, demo, and full-demo scripts to showcase local and Buildx integration.
- Updates documentation (README, examples) to explain installation, usage, and architecture.
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| main.go | New Go parser and Dockerfile generator for Agentfile frontend |
| Dockerfile | Multi-stage build image for the Go binary |
| build.sh, demo.sh, full-demo.sh | Scripts for building, testing, and demoing the frontend |
| README.md | Detailed documentation on usage, features, and future plans |
| test-build/Dockerfile(.bak), prompt.txt | Sample build context and prompt for testing frontend behavior |
| go.mod | Module definition and BuildKit dependency |
Comments suppressed due to low confidence (3)
agentfile-frontend/main.go:103
- Add unit tests for
AgentfileParser.ParseFile,ParseReader, andgenerateDockerfileto verify parser logic and output correctness, and to prevent future regressions.
func (p *AgentfileParser) ParseFile(filename string) (*AgentfileConfig, error) {
agentfile-frontend/README.md:78
- [nitpick] The syntax directive example is inconsistent. Standardize on the full registry identifier (e.g.,
# syntax=yeahdongcn/agentfile-frontend:latest) across all README examples.
# syntax=yeahdongcn/agentfile-frontend:latest
agentfile-frontend/test-build/Dockerfile.bak:1
- [nitpick] Remove the backup file
Dockerfile.bakfrom the test-build directory to avoid confusion and keep only the activeDockerfile.
# syntax=agentfile-frontend
|
|
||
| // Generate framework-specific code | ||
| dockerfile.WriteString("# Generate framework-specific code\n") | ||
| if config.Framework == "agno" { |
Copilot
AI
Jun 30, 2025
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 comparison against "agno" is case-sensitive. Consider normalizing config.Framework (e.g., strings.ToLower) or using a case-insensitive compare to handle inputs like "AGNO" correctly.
| if config.Framework == "agno" { | |
| if strings.ToLower(config.Framework) == "agno" { |
Summary by Sourcery
Add a new Go-based Docker Buildx frontend for Agentfile syntax that parses domain-specific Agentfile instructions and generates a Dockerfile with configuration files and framework-specific code. It introduces a CLI binary and a containerized image, along with documentation, build scripts, and example tests to demonstrate end-to-end usage.
New Features:
Build:
Documentation:
Tests: