Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@guillaume-sainthillier
Copy link
Member

Introduce a template-based architecture that significantly reduces code duplication and improves maintainability across all PHP variants.

What Changed

New Template System

  • Add CUE schema for version and variant configuration (templates/versions.cue)
  • Add validation rules and constraints (templates/validation.cue)
  • Add automated test suite for configuration validation (templates/test.sh)
  • Add Python-based generator script (templates/generate.py)

Dockerfile Templates

  • Create 4 reusable templates instead of maintaining 36+ individual files:
    • Dockerfile.base.tmpl - Apache + PHP on Debian
    • Dockerfile.symfony.tmpl - Symfony-optimized variant
    • Dockerfile.ci.tmpl - Alpine-based CI variant
    • Dockerfile.frankenphp.tmpl - FrankenPHP with Caddy

Build System Updates

  • Update Makefile with new targets: validate, test, generate
  • Integrate CUE validation into build process
  • Maintain backward compatibility with existing build commands

Documentation

  • Add comprehensive template system documentation (templates/README.md)
  • Update main README with template architecture overview
  • Include contributor quick start guide

Benefits

  • ✅ Reduced code duplication: 4 templates vs 36+ Dockerfiles
  • ✅ Guaranteed consistency across all variants
  • ✅ Built-in validation prevents configuration errors
  • ✅ Easy to add new PHP versions or variants
  • ✅ Single source of truth for all configurations
  • ✅ Faster development and maintenance

Technical Details

  • Uses CUE language for type-safe configuration
  • Generates byte-for-byte identical Dockerfiles
  • Validates version constraints (e.g., FrankenPHP >= 8.2)
  • Ensures proper legacy flags and latest tags
  • Automated testing of all configuration rules

All existing Dockerfiles remain functionally identical.

@guillaume-sainthillier guillaume-sainthillier force-pushed the claude/dockerfile-templates-01J3urTGADGc3AH56tmCiVpY branch 4 times, most recently from 6632da4 to 9855c4c Compare November 23, 2025 14:49
Replace 36+ individual Dockerfiles with a template-based system using
Python, Jinja2, and YAML configuration. All variants now use mlocati's
install-php-extensions for consistent dependency management.

Architecture:
- YAML configuration (templates/config.yaml) - Single source of truth
- Configuration validation (templates/validate_config.py) - Schema validation
- Jinja2 templates (4 files) - Base, Symfony, CI, FrankenPHP variants
- Generation script (templates/generate.py) - Automates creation

Key improvements:
- Use install-php-extensions (mlocati) for all PHP extension installations
- Automatic dependency handling across all PHP versions
- No manual --with-libzip or PHPIZE_DEPS configuration needed
- Support for legacy packages (iputils-ping, libicu-dev for PHP 5.6-7.3)
- Debian Stretch repository updates for PHP 7.1-7.3

Benefits:
- 4 templates instead of 36+ Dockerfiles
- YAML configuration with validation
- Guaranteed consistency across all images
- Simplified extension management with mlocati
- Easy to add new PHP versions or variants

Bug fixes:
- FrankenPHP Bookworm now uses apt-get instead of apk
- Debian Stretch repository updates for archived versions

Usage:
  make validate  # Validate configuration
  make generate  # Generate all Dockerfiles
  make build     # Build all images
@guillaume-sainthillier guillaume-sainthillier force-pushed the claude/dockerfile-templates-01J3urTGADGc3AH56tmCiVpY branch from 9855c4c to 4056349 Compare November 23, 2025 14:59
@guillaume-sainthillier guillaume-sainthillier deleted the claude/dockerfile-templates-01J3urTGADGc3AH56tmCiVpY branch December 8, 2025 13:48
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.

3 participants