Date: 2026-02-01 Status: Complete
Added comprehensive Docker container support to gearbox-agent as an alternative deployment method alongside the existing binary installation. This provides users with a containerized option for running the agent while maintaining full compatibility with the existing binary deployment.
- Multi-stage build using Go 1.25 and Alpine 3.23
- Security hardened (non-root user, minimal dependencies)
- Optimized for size (~47MB final image)
- Includes health check configuration
- Supports custom TLS certificates
- Build arguments for version, commit SHA, and build date
- Excludes build artifacts, tests, and documentation
- Keeps Swagger docs (required for build)
- Optimizes Docker context size
gearbox-agent/docker-compose.yml
- Complete production-ready configuration example
- Includes all environment variable options
- Volume mount examples for:
- Data persistence
- TLS certificates
- HAProxy socket access
- Systemd monitoring
- Security options configured
- Health check enabled
Comprehensive Docker installation and configuration guide covering:
- Quick start instructions
- Pre-built image usage
- Building from source
- Docker Compose setup
- Environment variable reference
- Volume mount configuration
- TLS certificate setup
- HAProxy monitoring scenarios
- Advanced configurations
- Troubleshooting guide
- Production deployment checklist
gearbox-agent/README.md - Updated
- Added Docker installation section
- Three installation options documented:
- Docker run
- Docker Compose
- Build from source
- Links to comprehensive Docker guide
README.md - Updated
- Added Docker installation examples
- Binary and Docker options documented
- Links to agent README and Docker guide
docs/getting-started.md - Updated
- Added Docker as recommended installation method
- Step-by-step Docker setup instructions
- Docker Compose example configuration
- Binary installation still documented as alternative
gearbox-agent/Makefile - Updated
New Docker targets added:
make docker-build # Build Docker image
make docker-push # Build and push to registry
make docker-run # Run container locally
make docker-stop # Stop and remove container
make docker-logs # View container logsVariables added:
DOCKER_REGISTRY- Container registry (default: ghcr.io)DOCKER_REPO- Repository nameDOCKER_IMAGE- Full image nameDOCKER_TAG- Image tag (default: VERSION)
.github/workflows/docker-agent.yml
GitHub Actions workflow for automated Docker builds:
- Triggers on push to main, version tags, and PRs
- Path filters (only builds when agent code changes)
- Multi-architecture support (amd64, arm64)
- Automatic tagging:
latestfor main branch- Semver tags (
v1.0.0,v1.0,v1) - Git SHA tags
- Branch tags
- Build caching for faster builds
- Publishes to GitHub Container Registry (ghcr.io)
- Build provenance attestation
.github/workflows/ci-agent.yml
Continuous integration workflow for agent:
- Test suite execution with race detection
- Code coverage reporting to Codecov
- golangci-lint checks
- Binary build verification
- Artifact upload for debugging
- Path filters to avoid unnecessary runs
.github/workflows/docker.yml - Updated
- Fixed image name from
haproxy-monitortogearbox - Added multi-architecture support (amd64, arm64)
- Added path filters for efficiency
gearbox/.dockerignore - Created
- Added for gearbox dashboard to match agent
- Optimizes build context
- Build Stage:
golang:1.25-alpine - Runtime Stage:
alpine:3.23
- Final image: ~47MB
- Multi-architecture: amd64, arm64
- Runs as non-root user (UID/GID 1000)
no-new-privilegessecurity option- Minimal runtime dependencies
- Self-signed TLS by default
- Support for custom certificates
Images are automatically published to GitHub Container Registry:
- Registry:
ghcr.io/sarg3nt/gearbox/gearbox-agent - Tags:
latest- Latest main branch buildv1.0.0- Specific versionmain- Latest main branchsha-abc123- Specific commit
cd gearbox-agent
docker build -t gearbox-agent:test .Result: ✅ Success Build time: ~7 seconds (with cache) Image size: 47.2MB
docker run -d --name test -p 8406:8405 gearbox-agent:test
docker exec test wget -q --spider --no-check-certificate https://localhost:8405/healthResult: ✅ Health check passed Startup time: ~1 second Memory usage: ~15MB
The following behaviors are normal in Docker:
⚠️ journalctlerrors - Expected in Alpine (no systemd)⚠️ HAProxy stats errors - Expected when not monitoring HAProxy⚠️ Certificate warnings - Expected with self-signed certificates
These are informational and do not affect core functionality.
| Feature | Binary | Docker |
|---|---|---|
| Setup Complexity | Medium | Low |
| System Requirements | systemd, Linux | Docker Engine |
| Isolation | None | Full container |
| Resource Overhead | Minimal | ~15MB RAM |
| Auto-restart | systemd | Docker restart policy |
| Update Process | systemctl restart | docker pull & restart |
| Log Access | journalctl | docker logs |
| Host Integration | Full | Limited (needs mounts) |
| Multi-server | Requires SSH | Standard Docker tooling |
docker pull ghcr.io/sarg3nt/gearbox/gearbox-agent:latest
docker run -d \
--name gearbox-agent \
-p 8405:8405 \
-v gearbox-agent-data:/var/lib/gearbox-agent \
ghcr.io/sarg3nt/gearbox/gearbox-agent:latestversion: '3.8'
services:
gearbox-agent:
image: ghcr.io/sarg3nt/gearbox/gearbox-agent:v1.0.0
container_name: gearbox-agent
restart: unless-stopped
ports:
- "8405:8405"
volumes:
- ./data:/var/lib/gearbox-agent
- /etc/letsencrypt/live/example.com:/etc/certs:ro
environment:
- HAPROXY_AGENT_TLS_CERT=/etc/certs/fullchain.pem
- HAPROXY_AGENT_TLS_KEY=/etc/certs/privkey.pem
- HAPROXY_AGENT_LOG_LEVEL=info
security_opt:
- no-new-privileges:truecd gearbox-agent
make docker-build
make docker-run
make docker-logs # View logs
make docker-stop # Clean upPotential improvements for future consideration:
- Distroless Image: Consider using distroless base for even smaller size
- Volume Plugins: Support for secret management (Docker Secrets, Vault)
- Kubernetes Support: Add Helm charts and k8s manifests
- ARM32 Support: Extend multi-arch to include ARM32 for Raspberry Pi
- Docker Healthcheck Script: Custom healthcheck script with more validation
- Environment File Support: Built-in support for .env files
- Init System: Consider s6-overlay or tini for better signal handling
None. This is a new deployment option that does not affect existing binary deployments.
For users currently running the binary:
- Binary deployment continues to work unchanged
- Docker can be adopted gradually
- Data can be migrated by copying
/var/lib/gearbox-agent - Configuration maps directly to environment variables
No action required for existing users.
All documentation has been updated to include Docker installation:
- ✅ gearbox-agent/README.md
- ✅ gearbox-agent/docs/docker.md (new)
- ✅ README.md
- ✅ docs/getting-started.md
- Dockerfile builds successfully
- Docker image runs without errors
- Health check passes
- API key generation works
- TLS certificates generate correctly
- Volume persistence works
- Multi-architecture builds configured
- GitHub workflows created
- Documentation complete
- Examples tested
- Makefile targets work
- Docker Compose example works
Docker support for gearbox-agent is now fully implemented and tested. Users have a choice between:
- Binary installation - Traditional systemd service deployment
- Docker installation - Containerized deployment with Docker or Docker Compose
Both methods are fully supported and documented, with Docker offering easier setup and better isolation, while binary installation provides tighter host integration.