Skip to content

Conversation

@ramonskie
Copy link
Contributor

Summary

  • Modernizes PHP buildpack packaging infrastructure by replacing the deprecated Ruby gem-based system with Go-based buildpack-packager
  • Eliminates Docker and Ruby dependencies for packaging while maintaining complete backward compatibility at runtime
  • Aligns PHP buildpack with all other Cloud Foundry buildpacks (go-buildpack, nodejs-buildpack, etc.)

Changes

Core Packaging

  • Added buildpack-packager::install function to scripts/.util/tools.sh
  • Refactored scripts/package.sh to use Go-based packager (similar to go-buildpack)
  • Updated scripts/brats.sh and scripts/integration.sh to use Go-based packager

Cleanup

  • Deleted obsolete cf.Gemfile and cf.Gemfile.lock
  • Removed cf.Gemfile references from manifest.yml exclude_files
  • Updated README.md with modernized packaging instructions

NewRelic Configuration Fix

  • Removed newrelic from default_versions in manifest.yml
  • Why: Go-based packager correctly validates semantic versions and rejects 4-part versions (10.21.0.11)
  • Runtime impact: None - NewRelic remains fully functional via compile-extensions fallback mechanism that automatically selects the single available version from dependencies

Testing

  • Net reduction: 47 lines of code (8 files changed, 52 insertions(+), 99 deletions(-))
  • All runtime functionality preserved
  • No breaking changes

Benefits

✅ Removes Ruby and Docker dependencies for packaging
✅ Aligns with CF buildpack ecosystem standards
✅ Simplifies CI/CD pipeline requirements
✅ Maintains 100% backward compatibility at runtime

Replace deprecated Ruby gem-based packaging with Go-based buildpack-packager,
bringing the PHP buildpack in line with all other Cloud Foundry buildpacks.

Changes:
- Add buildpack-packager::install function to scripts/.util/tools.sh
- Refactor scripts/package.sh to use Go-based packager
- Delete obsolete cf.Gemfile and cf.Gemfile.lock
- Update README.md with modernized packaging instructions
- Remove cf.Gemfile references from manifest.yml exclude_files
- Modernize scripts/brats.sh to use Go-based packager
- Enable buildpack-packager install in scripts/integration.sh (consistent with other buildpacks)
- Remove newrelic from default_versions in manifest.yml

The newrelic removal is required because the Go-based packager correctly
validates semantic versions and rejects 4-part versions (10.21.0.11).
NewRelic remains fully functional at runtime via compile-extensions
fallback mechanism that automatically selects the single available
version from the dependencies section.

This change eliminates Docker and Ruby dependencies for packaging while
maintaining complete backward compatibility at runtime.

Stats: 8 files changed, 52 insertions(+), 99 deletions(-)
Copy link

@ivanovac ivanovac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

ramonskie added a commit to cloudfoundry/buildpacks-ci that referenced this pull request Nov 6, 2025
All Cloud Foundry buildpacks now use compile_extensions: false and
Go-based packaging, making the legacy Ruby gem-based compile-extensions
infrastructure obsolete.

This change removes:
- compile-extensions git resource from pipeline
- buildpack-packager GitHub release resource from pipeline
- update-compile-extensions job
- update-buildpack-packager job
- Legacy Ruby bundler packaging logic from buildpack-tagger.rb
- Hardcoded PHP v4.5.3 Gemfile download URLs
- compile_extensions field from all buildpack values files

Impact:
- 66 lines removed from pipeline.yml
- 30 lines removed from buildpack-tagger.rb
- 2 task files deleted (update-compile-extensions)
- 14 buildpack values files cleaned up

This completes the buildpack modernization effort, ensuring all
buildpacks use consistent Go-based tooling. PHP buildpack packaging
was modernized in cloudfoundry/php-buildpack#1200.

Related: cloudfoundry/php-buildpack#1200
@ramonskie ramonskie marked this pull request as draft November 6, 2025 18:01
Add scripts/install_go.sh to download and install Go 1.22.5 during buildpack execution. This enables on-the-fly compilation of Go-based buildpack code, following the pattern used in the go-buildpack and ruby-buildpack reference implementations.
Implement supply, finalize, detect, release, start, and rewrite phases in Go:
- supply.go: Dependency installation, PHP/HTTPD/Nginx setup, extension management
- finalize.go: Final configuration and runtime preparation
- detect.go: Buildpack detection logic
- release.go: Release metadata generation
- start.go: Process manager for running multiple services
- rewrite.go: Configuration file template substitution

This migration aligns with Cloud Foundry's libbuildpack architecture used in reference buildpacks.
Convert all buildpack extensions to Go:
- extension.go: Base extension interface and lifecycle management
- appdynamics.go: AppDynamics APM integration
- composer.go: PHP Composer dependency management (856 lines)
- dynatrace.go: Dynatrace APM integration (524 lines)
- newrelic.go: New Relic APM integration
- sessions.go: PHP session storage configuration

Each extension implements compile-time and runtime hooks for modifying buildpack behavior.
Implement configuration system with embedded defaults:
- config.go: Configuration file discovery and management
- options.go: Options parsing from options.json with validation
- hooks.go: Lifecycle hook definitions
- config/defaults/: Embedded default configs for HTTPD, Nginx, PHP-FPM

Embedded defaults enable the buildpack to function without external dependencies. Includes comprehensive unit tests for options parsing.
Replace Python-based scripts with Go compilation wrappers:
- bin/detect: Compile and run detect.go
- bin/supply: Compile and run supply.go
- bin/finalize: Compile and run finalize.go
- bin/release: Compile and run release.go
- bin/start: Compile and run start.go
- bin/rewrite: Compile and run rewrite.go

All scripts follow consistent pattern: install Go, compile binary with -mod=vendor, execute with arguments. This matches the architecture of reference Cloud Foundry buildpacks.
Adjust integration test setup to work with Go compilation:
- init_test.go: Update test initialization and buildpack path handling
- apms_test.go: Update APM integration test expectations
- app_frameworks_test.go: Minor cleanup
- composer_test.go: Update Composer test expectations

Tests now account for Go compilation step during buildpack execution.
Add ARCHITECTURE.md (635 lines) documenting:
- Migration rationale and goals
- Go-based buildpack architecture
- Supply/finalize phase separation
- Extension system design
- Configuration management approach
- Comparison with Python implementation

Update .gitignore to exclude Go build artifacts and temporary files.
@ramonskie ramonskie closed this Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants