diff --git a/src/building-build-configs-php-munich/diagram.png b/src/building-build-configs-php-munich/diagram.png deleted file mode 100644 index 081415a..0000000 Binary files a/src/building-build-configs-php-munich/diagram.png and /dev/null differ diff --git a/src/building-build-configs-php-munich/example.mp4 b/src/building-build-configs-php-munich/example.mp4 deleted file mode 100644 index 02f1d7b..0000000 Binary files a/src/building-build-configs-php-munich/example.mp4 and /dev/null differ diff --git a/src/building-build-configs-php-munich/slides.rst b/src/building-build-configs-php-munich/slides.rst deleted file mode 100644 index 0f2dafb..0000000 --- a/src/building-build-configs-php-munich/slides.rst +++ /dev/null @@ -1,30 +0,0 @@ -.. footer:: @opdavies - -Building "Build Configs" -######################## - -.. class:: titleslideinfo - -Oliver Davies (@opdavies) - -| - -.. class:: titleslideinfo - -https://opdavi.es/bcm - -.. include:: ./sections/intro.rst -.. include:: ./sections/example.rst -.. include:: ./sections/customisation.rst -.. include:: ./sections/templates.rst -.. include:: ./sections/internals.rst - -.. raw:: pdf - - PageBreak titlePage - -.. class:: centredtitle - -Demo - -.. include:: ./sections/conclusion.rst diff --git a/src/building-build-configs-php-munich/code/generating-files.txt b/src/building-build-configs/code/generating-files.txt similarity index 100% rename from src/building-build-configs-php-munich/code/generating-files.txt rename to src/building-build-configs/code/generating-files.txt diff --git a/src/building-build-configs-php-munich/sections/conclusion.rst b/src/building-build-configs/sections/conclusion.rst similarity index 100% rename from src/building-build-configs-php-munich/sections/conclusion.rst rename to src/building-build-configs/sections/conclusion.rst diff --git a/src/building-build-configs-php-munich/sections/customisation.rst b/src/building-build-configs/sections/customisation.rst similarity index 100% rename from src/building-build-configs-php-munich/sections/customisation.rst rename to src/building-build-configs/sections/customisation.rst diff --git a/src/building-build-configs-php-munich/sections/example.rst b/src/building-build-configs/sections/example.rst similarity index 100% rename from src/building-build-configs-php-munich/sections/example.rst rename to src/building-build-configs/sections/example.rst diff --git a/src/building-build-configs-php-munich/sections/internals.rst b/src/building-build-configs/sections/internals.rst similarity index 100% rename from src/building-build-configs-php-munich/sections/internals.rst rename to src/building-build-configs/sections/internals.rst diff --git a/src/building-build-configs-php-munich/sections/intro.rst b/src/building-build-configs/sections/intro.rst similarity index 92% rename from src/building-build-configs-php-munich/sections/intro.rst rename to src/building-build-configs/sections/intro.rst index 83206bd..d302c15 100644 --- a/src/building-build-configs-php-munich/sections/intro.rst +++ b/src/building-build-configs/sections/intro.rst @@ -41,6 +41,10 @@ How Does it Work? .. image:: diagram.png :width: 18cm +.. raw:: pdf + + TextAnnotation "Canonical templates and project-specific configuration goes in, templates come out." + What Files Does it Generate? ============================ diff --git a/src/building-build-configs-php-munich/sections/templates.rst b/src/building-build-configs/sections/templates.rst similarity index 100% rename from src/building-build-configs-php-munich/sections/templates.rst rename to src/building-build-configs/sections/templates.rst diff --git a/src/building-build-configs/slides.rst b/src/building-build-configs/slides.rst index c2beb33..40cf57b 100644 --- a/src/building-build-configs/slides.rst +++ b/src/building-build-configs/slides.rst @@ -7,312 +7,16 @@ Building "Build Configs" Oliver Davies (@opdavies) -.. raw:: pdf - - PageBreak standardPage - -What is "Build Configs"? -======================== - -- Command-line tool. -- Inspired by Workspace, name from the TheAltF4Stream. -- Built with Symfony. -- Creates and manages build configuration files. -- Customisable per-project. -- Drupal, PHP library, Fractal (TypeScript). -- "Sprint zero in a box". - -What Problem Does it Solve? -=========================== - -- I work on multiple similar projects. -- Different configuration values - e.g. ``web`` vs. ``docroot``. -- Different versions of PHP, node, etc. -- Different Docker Compose (``fpm`` vs. ``apache`` images). -- Each project was separate. -- Difficult to add new features and fix bugs across all projects. -- Inconsistencies across projects. -- Out of the box solutions didn't seem like the best fit. - -.. raw:: pdf - - TextAnnotation "Multiple projects with similar but different configurations." - TextAnnotation "" - TextAnnotation "Out of the box solutions tend to focus on one technology, could be hard to customise, and usually had more than I nedeed." - TextAnnotation "" - TextAnnotation "Start small and build up instead of removing additional things." - TextAnnotation "" - TextAnnotation "More opportunities to learn the underlying technologies." - -How Does it Work? -================= - -.. image:: diagram.png - :width: 18cm - -What Files Does it Generate? -============================ - -- Dockerfile, Docker Compose, Nix Flake, php.ini, NGINX default.conf. -- ``run`` file. -- PHPUnit, PHPCS, PHPStan. -- GitHub Actions workflow. -- Git hooks. - -Example -======= - -build.yaml: - -.. code-block:: yaml - - name: my-example-project - type: drupal - language: php - - php: - version: 8.1-fpm-bullseye - | -Dockerfile: +.. class:: titleslideinfo -.. raw:: pdf +https://opdavi.es/bco - TextAnnotation "Abstract the project-specific values and configuration into this file." - -.. code-block:: yaml - - FROM php:8.1-fpm-bullseye AS base - -Configuring a Project -===================== - -.. code-block:: yaml - - php: - version: 8.1-fpm-bullseye - - # Which PHPCS standards should be used and on which paths? - phpcs: - paths: [web/modules/custom] - standards: [Drupal, DrupalPractice] - - # What level should PHPStan run and on what paths? - phpstan: - level: max - paths: [web/modules/custom] - -.. raw:: pdf - - PageBreak - -.. code-block:: yaml - - docker-compose: - # Which Docker Compose services do we need? - services: - - database - - php - - web - - dockerfile: - stages: - build: - # What commands do we need to run? - commands: - - composer validate --strict - - composer install - -.. raw:: pdf - - PageBreak - -.. code-block:: yaml - - web: - type: nginx # nginx, apache, caddy - - database: - type: mariadb # mariadb, mysql - version: 10 - - # Where is Drupal located? - drupal: - docroot: web # web, docroot, null - - experimental: - createGitHubActionsConfiguration: true - runGitHooksBeforePush: true - useNewDatabaseCredentials: true - -.. raw:: pdf - - TextAnnotation "Experimental opt-in features that I want to trial on certain projects or to disable non-applicable features - e.g. GitHub Actions on Bitbucket." - - PageBreak - -Overriding Values -================= - -.. code-block:: yaml - - php: - version: 8.1-fpm-bullseye - # Disable PHPCS, PHPStan and PHPUnit. - phpcs: false - phpstan: false - phpunit: false - - # Ignore more directories from Git. - git: - ignore: - - /bin/ - - /libraries/ - - /web/profiles/contrib/ - -.. raw:: pdf - - TextAnnotation "Drupal Commerce Kickstart demo. No custom modules to test, and additional paths to ignore from Git." - - PageBreak - -.. code-block:: yaml - - dockerfile: - stages: - build: - # What additional directories do we need? - extra_directories: - - config - - patches - - scripts - - commands: - - composer validate --strict - - composer install - - # What additional PHP extensions do we need? - extensions: - install: [bcmath] - -.. raw:: pdf - - TextAnnotation "Extra directories and PHP extensions that need to be added". - -Dockerfile.twig -=============== - -.. code-block:: twig - :linenos: - - FROM php:{{ php.version }} AS base - - COPY --from=composer:2 /usr/bin/composer /usr/bin/composer - RUN which composer && composer -V - - ARG DOCKER_UID=1000 - ENV DOCKER_UID="${DOCKER_UID}" - - WORKDIR {{ project_root }} - - RUN adduser --disabled-password --uid "${DOCKER_UID}" app \ - && chown app:app -R {{ project_root }} - -Dockerfile.twig -=============== - -.. code-block:: twig - :linenos: - - {% if dockerfile.stages.build.extensions.install %} - RUN docker-php-ext-install - {{ dockerfile.stages.build.extensions.install|join(' ') }} - {% endif %} - - COPY --chown=app:app phpunit.xml* ./ - - {% if dockerfile.stages.build.extra_files %} - COPY --chown=app:app {{ dockerfile.stages.build.extra_files|join(" ") }} ./ - {% endif %} - - {% for directory in dockerfile.stages.build.extra_directories %} - COPY --chown=app:app {{ directory }} {{ directory }} - {% endfor %} - -docker-compose.yaml.twig -======================== - -.. code-block:: twig - :linenos: - - services: - {% if "web" in dockerCompose.services %} - web: - <<: [*default-proxy, *default-app] - build: - context: . - target: web - depends_on: - - php - profiles: [web] - {% endif %} - -phpstan.neon.dist.twig -====================== - -.. code-block:: twig - :linenos: - - parameters: - level: {{ php.phpstan.level }} - excludePaths: - - *Test.php - - *TestBase.php - paths: - {% for path in php.phpstan.paths -%} - - {{ path }} - {%- endfor %} - - {% if php.phpstan.baseline %} - includes: - - phpstan-baseline.neon - {% endif %} - -phpunit.xml.dist.twig -===================== - -.. code-block:: twig - :linenos: - - - -phpunit.xml.dist.twig -===================== - -.. code-block:: twig - :linenos: - - - - ./{{ drupal.docroot }}/modules/custom/**/tests/**/Functional - - - ./{{ drupal.docroot }}/modules/custom/**/tests/**/Kernel - - - ./{{ drupal.docroot }}/modules/custom/**/tests/**/Unit - - +.. include:: ./sections/intro.rst +.. include:: ./sections/example.rst +.. include:: ./sections/customisation.rst +.. include:: ./sections/templates.rst .. raw:: pdf @@ -322,30 +26,4 @@ phpunit.xml.dist.twig Demo -.. raw:: pdf - - PageBreak standardPage - -Result -====== - -- Easier and faster to create and onboard projects. -- One canonical source of truth. -- Easy to add new features and fixes for all projects. -- Automation is easier due to consistency (e.g. Docker Compose service names). - -Thanks! -======= - -References: - -- https://opdavi.es/build-configs -- https://github.com/opdavies/docker-example-drupal -- https://github.com/opdavies/docker-example-drupal-commerce-kickstart -- https://github.com/opdavies/docker-example-drupal-localgov - -| - -Me: - -- https://www.oliverdavies.uk +.. include:: ./sections/conclusion.rst