Skip to content

[!!!][TASK] Generate the Dockerfiles and conf/ in PHP with Twig and remove the Python generator - #604

Merged
Kanti merged 2 commits into
webdevops:masterfrom
andersundsehr:feature/twig-templates
Nov 11, 2026
Merged

Kanti merged 2 commits into
webdevops:masterfrom
andersundsehr:feature/twig-templates

Conversation

@Kanti

@Kanti Kanti commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Caution

Merge with "Rebase and merge", not "Squash and merge"

The first commit only renames files, the second changes them. A squash would lose the history of template/Dockerfile/layout.twig: only 4 of its 22 lines stay the same, too few for Git to see the rename.

Summary

make generate writes every generated file in PHP: the Dockerfiles from Twig templates, their conf/ from provisioning/, .github/workflows/build.yaml and the README banner. It runs composer install and ci/console generate in webdevops/php:8.4-alpine as the calling user, so only make and Docker are needed. The Python 2 generator behind make provision (bin/) is removed, and so is Python 2 in webdevops/dockerfile-build-env. The images stay the same apart from one trailing space in four Dockerfiles.

[!!!] because make provision no longer exists for contributors and the templates are Twig templates now.

Changes

  • generate:dockerfile renders the Dockerfiles with Twig and keeps the links docker/php/<tag>. generate:provision copies provisioning/ into conf/ as conf/provision.yml says and checks the whole file first. generate runs all four generators.
  • github:generate-ci and readme-banner:generate become generate:github-ci and generate:readme-banner.
  • make generate, make check (GrumPHP) and make test (PHPUnit) run as the calling user. The CI runs make generate and make check.
  • Removed: bin/, the Makefile targets provision, requirements, list and setup, Python 2 in dockerfile-build-env.
  • 248 PHPUnit tests; README, AGENTS.md and docs/ updated.

Closes #549. Replaces the pull requests #451 and #548, which move the generator to Python 3: here it is rewritten in PHP.

All changes and how each was verified: andersundsehr#16

Only renames without any change of content, so that Git keeps the
history of every file:

- template/**/*.jinja2 and docker/<image>/<tag>/Dockerfile.jinja2
  become .twig, also the template of the test repository.
- GithubCommand and ReadmeBannerCommand and their tests become
  GenerateGithubCiCommand and GenerateReadmeBannerCommand.

The next commit changes their content. Until then neither
make provision nor ci/console works.
…emove the Python generator

make generate runs composer install and ci/console generate in
webdevops/php:8.4-alpine as the calling user, and ci/console generate
writes every generated file in PHP:

- generate:dockerfile renders docker/<image>/<tag>/Dockerfile with Twig
  (strict_variables). template/Dockerfile/layout.twig writes the header
  and includes the Dockerfile.twig of the tag. A tag directory with
  files but no Dockerfile.twig is an error: nothing would update it,
  but generate:github-ci would still build and publish its Dockerfile.
  It keeps the links docker/php/<tag> to docker/php-official/<tag> and
  first removes the .DS_Store files of the macOS Finder under docker/.
- generate:provision copies provisioning/ into conf/ as
  conf/provision.yml says, like bin/console did: it empties the conf/
  directories of an image first, copies the sources in the order of the
  file and keeps the file permissions. It checks the whole file first
  and stops if a source or a tag does not exist, or if an image has
  another setting than "configuration". A tag pattern has to match the
  whole tag now; no tag in the repository is affected.
- github:generate-ci and readme-banner:generate are renamed to
  generate:github-ci and generate:readme-banner. generate:github-ci
  names the directory to remove when an image builds on or copies from
  a webdevops image that is not built any more.
- TagDirectories is the one list of tags (directories with a
  Dockerfile.twig, without the links docker/php/<version>) for both
  generators and FileReader.

The templates are Twig templates:

- A Dockerfile.twig imports the macros it uses from
  template/Dockerfile/, e.g. {% import 'docker.twig' as docker %}. A
  macro imports the macros it calls in its own body, because Twig
  macros do not see the imports of their file.
- Tags alone on a line need no "-", because Twig removes the line break
  after a tag by itself; elif becomes elseif; baselayout.copy(), whose
  output starts with a line break, gets an empty first line.
- externalExtensions() moves from php.twig to images/php-extensions.twig
  as external(), because Twig only calls a macro of the same file after
  importing it.
- The comment "Check if needed" in the four Alpine php-official
  templates moves above phpOfficialSendmailWorkaround(). The trailing
  space after ENV PHP_SENDMAIL_PATH in php-official 8.2- to 8.5-alpine
  disappears, the only change in the Dockerfiles.

make check installs the PHP tools of ci/ and runs GrumPHP as the
calling user, make test only the PHPUnit tests. The CI runs
make generate and fails on a changed or a new file, and it runs
make check.

Removed: bin/ (the Python 2 generator), the Makefile targets provision,
requirements, list and setup, tests/serverspec/__init__.py,
tests/structure-test/install.sh, the settings in conf/console.yml that
only bin/ read, and in webdevops/dockerfile-build-env Python 2, pip and
the clone of the repository whose gems docker-image-cleanup deleted
again. README, AGENTS.md and docs/ describe make generate, make check
and the templates.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
5.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

This was referenced Nov 11, 2026
@Kanti
Kanti marked this pull request as ready for review November 11, 2026 06:32
@Kanti
Kanti merged commit 6d5f0d2 into webdevops:master Nov 11, 2026
177 of 178 checks passed
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.

Upgrade python to V3

1 participant