Agent Forge Docker Build Integration
Status: 🟢 In-use Category: Integrations Date: October 30, 2025 (consolidated November 5, 2025)
Overview​
The GitHub Action workflow has been configured to use a custom Dockerfile from build/agent-forge/Dockerfile instead of relying on a Dockerfile from the cloned community-plugins repository. This enables automated building and publishing of the Backstage Agent Forge plugin as a Docker image to GitHub Container Registry (ghcr.io).
Why Use a Custom Dockerfile?​
The custom Dockerfile provides several optimizations:
- ARM64 Compatibility - Includes specific configurations for ARM64 architecture support
- Build Optimization - Better layer caching with strategic COPY commands
- Memory Management - Sets
NODE_OPTIONS="--max-old-space-size=4096"for large builds - Fallback Handling - Includes retry logic for yarn install failures
- Workspace-Specific - Targets the
workspaces/agent-forgedirectory
Dockerfile Analysis​
The Dockerfile at build/agent-forge/Dockerfile:
FROM node:20-bookworm-slim
WORKDIR /app
# Install dependencies for both architectures
RUN apt-get update && apt-get install -y \
git \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy package files first for better caching
COPY package.json yarn.lock .yarnrc.yml ./
COPY workspaces/agent-forge/package.json ./workspaces/agent-forge/
# Set yarn configuration for better ARM64 compatibility
ENV YARN_CACHE_FOLDER=/tmp/.yarn-cache
ENV NODE_OPTIONS="--max-old-space-size=4096"
# Install dependencies with ARM64 optimizations
RUN yarn install --frozen-lockfile --network-timeout 600000 || \
(yarn config set supportedArchitectures.cpu "current" && \
yarn install --network-timeout 600000)
# Copy the rest of the application
COPY . .
WORKDIR /app/workspaces/agent-forge
EXPOSE 3000
CMD ["yarn", "start"]
Key Features:​
- Base Image:
node:20-bookworm-slim- lightweight Debian-based Node.js 20 - System Dependencies: Git, Python3, Make, G++ for native module compilation
- Layer Caching: Copies package files before source code for better caching
- Memory Allocation: 4GB max old space size for large builds
- Network Timeout: Extended timeout for slow connections
- Architecture Fallback: Automatically adjusts for current architecture if needed
- Port: Exposes port 3000 for the application
How the Workflow Uses It​
Workflow Steps:​
-
Checkout Both Repositories:
- name: Checkout current repository
uses: actions/checkout@v4
with:
path: main-repo
- name: Checkout community-plugins repository
uses: actions/checkout@v4
with:
repository: cnoe-io/community-plugins
ref: agent-forge-upstream-docker
path: community-plugins -
Copy Custom Dockerfile:
- name: Copy custom Dockerfile
run: |
cp main-repo/build/agent-forge/Dockerfile community-plugins/Dockerfile
echo "Using custom Dockerfile from build/agent-forge/" -
Build with Custom Dockerfile:
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: community-plugins
file: community-plugins/Dockerfile
platforms: linux/amd64,linux/arm64
Advantages of This Approach​
1. Version Control​
- Dockerfile is tracked in your repository
- Changes are versioned with your code
- Easy to review and audit
2. Customization​
- Full control over build environment
- Can add custom dependencies
- Can optimize for specific architectures
3. Consistency​
- Same Dockerfile used locally and in CI/CD
- Predictable build behavior
- Easy to troubleshoot
4. Portability​
- Don't depend on upstream Dockerfile existence
- Can switch branches/repos without issues
- Independent of community-plugins structure
Testing Locally​
The local test script (test-build-locally.sh) also uses your custom Dockerfile:
# Run the local test
./.github/test-build-locally.sh
The script will:
- Clone the community-plugins repository
- Copy your custom Dockerfile
- Build the project
- Create the Docker image
- Offer to run the container
Modifying the Dockerfile​
If you need to modify the Dockerfile:
-
Edit the file:
nano build/agent-forge/Dockerfile -
Test locally:
./.github/test-build-locally.sh -
Commit and push:
git add build/agent-forge/Dockerfile
git commit -m "Update agent-forge Dockerfile"
git push -
Workflow will use the updated version automatically on next run
Common Modifications​
Add Environment Variables​
# Add after ENV NODE_OPTIONS line
ENV BACKSTAGE_HOST=0.0.0.0
ENV BACKSTAGE_PORT=3000
Add Additional Dependencies​
# Add to the apt-get install command
RUN apt-get update && apt-get install -y \
git \
python3 \
make \
g++ \
curl \
jq \
&& rm -rf /var/lib/apt/lists/*
Change the Working Directory​
# Change the final WORKDIR if needed
WORKDIR /app/workspaces/your-workspace
Multi-Stage Build​
# Add a build stage
FROM node:20-bookworm-slim AS builder
WORKDIR /app
# ... build steps ...
# Runtime stage
FROM node:20-bookworm-slim AS runtime
WORKDIR /app
COPY --from=builder /app/dist ./dist
# ... runtime configuration ...
Port Configuration​
The Dockerfile exposes port 3000, but you can customize this:
In Dockerfile:​
EXPOSE 7007
In Docker Run:​
docker run -p 7007:3000 ghcr.io/cnoe-io/backstage-plugin-agent-forge:latest
In Workflow (if needed):​
You can also pass build arguments:
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: community-plugins
file: community-plugins/Dockerfile
build-args: |
PORT=7007
Troubleshooting​
Build Fails on ARM64​
If builds fail on ARM64:
- Check the yarn install fallback is working
- Consider adding more memory:
NODE_OPTIONS="--max-old-space-size=8192" - Test locally on ARM64 machine or use Docker buildx
Build is Slow​
To speed up builds:
- Ensure layer caching is working (COPY package files first)
- Use
.dockerignoreto exclude unnecessary files - Consider using a more powerful runner in GitHub Actions
- Use the build cache:
cache-from: type=gha
Image is Too Large​
To reduce image size:
- Use multi-stage builds
- Remove build dependencies in final stage
- Use
.dockerignoreto exclude test files, docs, etc. - Clean yarn cache:
RUN yarn cache clean
Best Practices​
- Keep it Simple: Don't add unnecessary dependencies
- Use Multi-Stage: Separate build and runtime stages
- Cache Layers: Order commands from least to most frequently changing
- Security: Use official base images and keep them updated
- Document: Comment complex commands in the Dockerfile
- Test: Always test changes locally before pushing
Integration with CI/CD​
The workflow automatically:
- ✅ Uses the latest version of your Dockerfile
- ✅ Builds for multiple architectures (amd64, arm64)
- ✅ Caches layers for faster subsequent builds
- ✅ Tags images appropriately
- ✅ Pushes to GitHub Container Registry
No additional configuration needed!
Docker Image Details​
Registry: GitHub Container Registry (ghcr.io)
Image Name: ghcr.io/cnoe-io/backstage-plugin-agent-forge
Available Tags:
latest- Latest stable build<branch>- Branch-specific builds<branch>-<sha>- Commit-specific builds<version>- Semantic version tags
Pull the Image​
docker pull ghcr.io/cnoe-io/backstage-plugin-agent-forge:latest
Run the Container​
docker run -d \
-p 7007:3000 \
--name agent-forge-plugin \
ghcr.io/cnoe-io/backstage-plugin-agent-forge:latest
Files Created​
GitHub Action Workflow​
.github/workflows/build-agent-forge-plugin.yml- Main workflow.github/workflows/README.md- Workflow documentation.github/WORKFLOW_SETUP.md- Setup guide.github/test-build-locally.sh- Local testing script.github/verify-setup.sh- Setup verification script
Next Steps​
- Review the Dockerfile to ensure it meets your needs
- Test locally using the test script
- Commit the workflow files
- Push to GitHub to trigger the workflow
- Monitor the build in the Actions tab
Date Added: October 30, 2025
Dockerfile Location: build/agent-forge/Dockerfile
Workflow: .github/workflows/build-agent-forge-plugin.yml
Related Documentation: .github/workflows/README.md, .github/WORKFLOW_SETUP.md
Agent Forge GitHub Action Workflow Setup
Overview​
A GitHub Action workflow has been created to automatically build and push the Backstage Agent Forge plugin Docker image to GitHub Container Registry.
Files Created​
1. .github/workflows/build-agent-forge-plugin.yml​
The main workflow file that orchestrates the build and push process.
Key Features:
- ✅ Uses custom Dockerfile from
build/agent-forge/Dockerfile - ✅ Clones
https://github.com/cnoe-io/community-plugins.git(branch:agent-forge-upstream-docker) - ✅ Sets up Node.js 20 environment with Yarn
- ✅ Installs dependencies and builds the project
- ✅ Builds multi-platform Docker image (amd64 & arm64)
- ✅ Pushes to
ghcr.io/cnoe-io/backstage-plugin-agent-forge - ✅ Automatic tagging (latest, branch name, SHA, semantic versions)
- ✅ Build caching for faster subsequent runs
- ✅ Supply chain security with attestations
2. .github/workflows/README.md​
Comprehensive documentation including:
- Workflow triggers and behavior
- Usage instructions
- Troubleshooting guide
- Customization options
- Security considerations
Docker Image Details​
Registry: GitHub Container Registry (ghcr.io)
Image Name: ghcr.io/cnoe-io/backstage-plugin-agent-forge
Available Tags:
latest- Latest stable build<branch>- Branch-specific builds<branch>-<sha>- Commit-specific builds<version>- Semantic version tags
Quick Start​
Pull the Image​
docker pull ghcr.io/cnoe-io/backstage-plugin-agent-forge:latest
Run the Container​
docker run -d \
-p 7007:7007 \
--name agent-forge-plugin \
ghcr.io/cnoe-io/backstage-plugin-agent-forge:latest
Triggering the Workflow​
The workflow can be triggered in three ways:
1. Automatic (Push)​
Push to main or develop branch:
git push origin main
2. Pull Request​
Open a PR targeting the main branch
3. Manual Trigger​
- Navigate to Actions tab in GitHub
- Select Build and Push Agent Forge Plugin
- Click Run workflow
- Choose branch and click Run workflow button
Prerequisites Checklist​
Before running the workflow, ensure:
- Custom Dockerfile exists at
build/agent-forge/Dockerfile(✓ already present) - Repository has GitHub Actions enabled
-
GITHUB_TOKENhas package write permissions (Settings → Actions → General → Workflow permissions) - The
cnoe-io/community-pluginsrepository is accessible - Branch
agent-forge-upstream-dockerexists in community-plugins - Repository settings allow package publishing
Configuration Settings​
GitHub Repository Settings​
-
Enable Package Publishing:
- Go to Settings → Actions → General
- Under "Workflow permissions", select "Read and write permissions"
- Check "Allow GitHub Actions to create and approve pull requests"
-
Package Visibility:
- Go to the package settings after first build
- Set visibility to "Public" if needed
Workflow Customization​
To customize the workflow, edit .github/workflows/build-agent-forge-plugin.yml:
# Change trigger branches
on:
push:
branches:
- main
- your-branch
# Change source repository/branch
- uses: actions/checkout@v4
with:
repository: cnoe-io/community-plugins
ref: your-branch-name
# Change Docker build settings
platforms: linux/amd64,linux/arm64
Monitoring and Logs​
View Workflow Status​
- Go to your repository on GitHub
- Click the Actions tab
- Select the workflow run to view logs
Check Published Packages​
- Navigate to your repository homepage
- Click Packages in the right sidebar
- View
backstage-plugin-agent-forgepackage
Download Artifacts​
The workflow creates attestations for supply chain security:
- Available in the workflow run under "Artifacts"
- Automatically pushed to the registry
Advanced Usage​
Building for Specific Platforms​
Edit the workflow to build for specific platforms:
platforms: linux/amd64 # Only amd64
# or
platforms: linux/arm64 # Only arm64
Custom Build Arguments​
Add build arguments:
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
build-args: |
NODE_ENV=production
VERSION=${{ github.sha }}
Conditional Execution​
Run only on specific conditions:
- name: Build and push Docker image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Troubleshooting​
Common Issues​
Problem: Workflow fails at checkout step
Solution: Verify the repository URL and branch name are correct
Problem: Build fails with "command not found"
Solution: Check that the build commands in package.json are correct
Update Node.js version if needed
Problem: Cannot push to ghcr.io
Solution: Enable write permissions for GITHUB_TOKEN in repository settings
Path: Settings → Actions → General → Workflow permissions
Problem: Custom Dockerfile not found
Solution: Ensure build/agent-forge/Dockerfile exists in your repository
The workflow copies this file to the community-plugins directory
Next Steps​
- Commit and push the workflow files to your repository
- Configure repository permissions for package publishing
- Trigger the workflow manually or via push
- Monitor the build in the Actions tab
- Verify the image is available at
ghcr.io/cnoe-io/backstage-plugin-agent-forge:latest
Support​
For issues or questions:
- Review the workflow logs in the Actions tab
- Check the GitHub Actions documentation
- Verify the community-plugins repository
Date Added: October 30, 2025 Workflow Version: 1.0 Maintainer: Platform Engineering Team Related Documentation: Agent Forge Docker Build Integration