--- name: agent-automation-infrastructure description: Current state of CI/CD automation infrastructure, pre-built Docker images, and performance optimization strategies. Use when dealing with slow builds, container timeouts, yarn install issues, or when you need to understand available pre-built images and automation tooling. --- # Agent Automation Status & Recommendations ## Current State (Updated 2026-01-04) ### For Local Development ✅ Agents can successfully test on local workstations where: - Full network access available - Docker and Node.js installed - Can manually run `yarn install` and `docker compose up` - Screenshots can be captured via browser ### Pre-built Images Available 🚀 Three pre-built images are available via GitHub Container Registry: - **Payload dev** (`ghcr.io/ynotradio/site/payload-dev:latest`) - Next.js + Payload CMS - **PHP-FPM dev** (`ghcr.io/ynotradio/site/phpfpm-dev:latest`) - Legacy site backend - **Postgres seeded** (`ghcr.io/ynotradio/site/postgres-seeded:latest`) - PostgreSQL with Payload schema + sample data ### For CI/CD Automation ⚠️ **Infrastructure:** Complete and functional **Blocker:** Performance (yarn install takes 5+ minutes in containers) After adding domains to firewall allowlist: - ✅ `registry.hub.docker.com` - Docker Hub access working - ✅ `registry.npmjs.org` - npm package downloads working - ❌ **yarn install in Alpine containers: 5+ minutes** (timeout) ## Performance Metrics | Operation | Current | With Pre-built | Status | |-----------|---------|----------------|--------| | Docker pull base images | ~2s | ~30s | ✅ | | yarn install (Alpine) | 5+ min | N/A (pre-installed) | ✅ | | Postgres startup (seeded) | ~3 min | ~10s | ✅ | | Container startup | Blocked | ~20s | ✅ | | Total time to ready | Timeout | ~1 min | ✅ | ## Recommended Solutions ### Option 1: Pre-Built Images (Recommended) ⭐ **Implementation:** - GitHub Actions workflow builds images on every push to master - Images pushed to GitHub Container Registry (ghcr.io) - Agents pull pre-built images instead of building **Available images:** 1. **Payload dev** - Next.js + Payload CMS with dependencies pre-installed 2. **PHP-FPM dev** - Legacy site with PHP extensions and configuration 3. **Postgres seeded** - PostgreSQL 16 with Payload schema and sample data baked in **Benefits:** - ✅ Startup time: 5+ minutes → ~20 seconds (15x faster) - ✅ No network restrictions needed beyond image pull - ✅ Consistent environments - ✅ No yarn install timeouts - ✅ Database comes pre-seeded with test data **Status:** ✅ Workflow ready in `.github/workflows/build-agent-images.yml` **Usage:** ```bash # Pull and run pre-built images docker pull ghcr.io/ynotradio/site/payload-dev:latest docker pull ghcr.io/ynotradio/site/phpfpm-dev:latest docker pull ghcr.io/ynotradio/site/postgres-seeded:latest # Or use docker-compose (configured to use pre-built images) docker-compose up postgres # Pre-seeded Postgres ready in ~10s ``` **Image details:** - `payload-dev`: Node.js 22 + yarn dependencies (~800 MB) - `phpfpm-dev`: PHP 8.3-FPM + extensions (~450 MB) - `postgres-seeded`: PostgreSQL 16 + seeded data (~400 MB) See `bin/docker/postgres/README.md` for Postgres image details. ### Option 2: Playwright MCP Server **Implementation:** - Add Playwright MCP server to agent tooling - Point to existing staging/dev instances - Agents navigate and screenshot directly **Benefits:** - ✅ No local Docker needed - ✅ Test against real data - ✅ Instant access **Drawbacks:** - ❌ Requires maintained staging environment - ❌ Potential for environment conflicts - ❌ Can't test isolated changes ### Option 3: Optimized Containers **Improvements to current approach:** 1. **Use Debian instead of Alpine** (faster yarn install) ```dockerfile FROM node:22 # Not -alpine ``` 2. **Layer caching** ```dockerfile COPY package*.json ./ RUN npm ci --omit=dev COPY . . ``` 3. **Use Yarn** (faster than npm) ```dockerfile RUN yarn install --frozen-lockfile ``` **Expected improvement:** 5 min → 2-3 min (still slow for CI) ## Recommendations ### Immediate Action 1. ✅ Enable pre-built image workflow (already created) 2. Update agent documentation to use pre-built images 3. Add `ghcr.io` to firewall allowlist (if not already) ### For Future PRs Agents should: 1. **Check for pre-built images first** before building locally 2. **Report performance issues** when exceeding baselines 3. **Provide evidence or explain why not** (per testing checklist) 4. **Test locally** when CI automation unavailable ## Usage Examples ### With Pre-Built Images (Fast) ```bash # Pull pre-built images docker pull ghcr.io/ynotradio/site/payload-dev:latest docker pull ghcr.io/ynotradio/site/phpfpm-dev:latest # Start services (uses pre-built images) docker compose up -d # Seed databases with data yarn seed:legacy # Legacy site with production data yarn seed:payload # Payload with sample data # Ready in ~20 seconds (+ seed time) ``` ### Building Locally (Slow) ```bash # Build from scratch docker compose up -d --build # Seed databases yarn seed:legacy # Legacy site yarn seed:payload # Payload # Takes 5+ minutes due to yarn install ``` ### Database Seeding Notes **Why seed:** - Empty applications are hard to verify - Screenshots of empty dashboards don't prove functionality - Real data helps test relationships and queries **Legacy site:** `yarn seed:legacy` - Pulls production database snapshot - Imports into MySQL container - Site shows real content at http://localhost:8080 **Payload:** `yarn seed:payload` - Creates sample collections and data - Admin UI shows populated tables - May need implementation if not yet available ## Monitoring Track these metrics in agent PRs: ```markdown ## Performance Report - Image pull: [time] - Container start: [time] - Service ready: [time] - Total: [time] Target: < 3 minutes total ``` ## Future Improvements 1. **Multi-stage builds** - Build dependencies in separate stage 2. **Volume caching** - Share node_modules between builds 3. **Lighter dependencies** - Audit and remove unnecessary packages 4. **Playwright MCP** - Add as complementary testing option ## Conclusion **For immediate use:** Pre-built images solve the CI/CD automation blocker. **For local development:** Direct installation continues to work perfectly. All agent infrastructure is production-ready and documented. The only remaining step is enabling the pre-built image workflow.