### yq install.yml example Source: https://github.com/devilbox/docker-php-fpm/blob/master/php_tools/README.md Example install.yml for the yq tool. Defines a check command and a pip installation with empty dependency lists. ```yaml --- check: yq --version 2>&1 | grep -E '[0-9][.0-9]+' || (yq --version; false) all: type: pip version: build_dep: [] run_dep: [] pre: post: ``` -------------------------------- ### Example: type apt configuration Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-TOOL-install.yml.md Example YAML defining 'type: apt' for installing Debian packages. Required key: 'package'. No shell code support. ```yaml all: type: apt package: netcat 5.3: type: apt package: netcat.traditional ``` -------------------------------- ### Example YAML for type: custom with multi-stage build note Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-TOOL-install.yml.md Shows a custom install command and a version-specific override. The `command` key is required and must install tools into /usr/local/bin because only that directory is copied during multi-stage builds. ```yaml all: type: custom command: curl -sS -k -L --fail -L "${PHP_CS_FIXER_URL}" -o /usr/local/bin/php-cs-fixer pre: PHP_CS_FIXER_URL="https://cs.symfony.com/download/php-cs-fixer-v3.phar" post: chmod +x /usr/local/bin/php-cs-fixer 7.3: type: custom pre: PHP_CS_FIXER_URL="https://cs.symfony.com/download/php-cs-fixer-v2.phar" ``` -------------------------------- ### Defining module installation dependencies and hooks Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-EXT-install.yml.md Example of configuring build and runtime dependencies along with pre and post installation shell commands for a builtin module type. ```yaml all: type: builtin pre: | ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE))" \ post: | rm -f /tmp/file.txt \ build_dep: [libmcrypt-dev] run_dep: [libmcrypt4] 8.1: type: builtin build_dep: [] run_dep: [] ``` -------------------------------- ### Example: type npm configuration Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-TOOL-install.yml.md Example YAML defining 'type: npm' for installing NPM packages. Required key: 'package'. Optional keys: 'version' and 'binary'. ```yaml all: type: npm package: pm2 binary: pm2 version: ``` -------------------------------- ### install.yml example with check, all, and version override Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-TOOL-install.yml.md Example YAML for a tool definition. The 'check' command verifies installation, 'all' provides defaults for all PHP versions, and a version-specific block (5.2) overrides the version. The 'all' block includes empty build_dep and run_dep arrays. ```yaml check: yq --version 2>&1 | grep -E '[0-9][.0-9]+' || (yq --version; false) # Default for all PHP version if no overwrite exists all: type: pip version: build_dep: [] run_dep: [] pre: post: # PHP 5.2 is overwriting the version of yq to install 5.2: type: pip version: 0.1.0 ``` -------------------------------- ### yq options.yml example Source: https://github.com/devilbox/docker-php-fpm/blob/master/php_tools/README.md Example options.yml for the yq tool. The name must match the directory, exclude lists PHP versions to skip, and depends lists required tools. ```yaml --- name: yq # The name must match the directory exclude: [] # Any PHP versions to exclude? depends: [jq] # The jq tool must be installed (yq depends on it) ``` -------------------------------- ### Example YAML for type: rubygem Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-TOOL-install.yml.md Configures a Ruby gem installation with the required `package` key and optional `version`. The example shows a base definition for all versions and an override for version 7.2. ```yaml all: type: rubygem package: mdl build_dep: [ruby-dev] run_dep: [ruby] 7.2: type: rubygem version: 0.11.0 pre: | gem install chef-utils -v 16.6.14 \ ``` -------------------------------- ### Custom command for PHP extension installation Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-EXT-install.yml.md Example of a custom command definition using the 'command' key to download, compile, and install a PHP module. ```yaml all: type: custom command: | wget http://url/file.tar.gz \ && tar xvfz file.tar.gz \ && cd file \ && phpize \ && ./configure \ && make \ && make install \ ``` -------------------------------- ### Example YAML for type: pip installation Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-TOOL-install.yml.md Shows a minimal pip-type configuration. The package name defaults to the `name` in options.yml. The `version` key is optional and supports shell code. ```yaml all: type: pip version: build_dep: [] run_dep: [] pre: post: | ln -s pwncat /usr/local/bin/netcat \ ``` -------------------------------- ### Example: type composer configuration Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-TOOL-install.yml.md Example YAML defining 'type: composer' for installing Composer packages. Required keys: 'package' and 'composer' (1 or 2). Supports shell code for 'version', 'binary', and 'flags'. ```yaml all: type: composer composer: 2 package: laravel/installer binary: bin/laravel 7.1: type: composer version: 2.3.0 binary: laravel ``` -------------------------------- ### Configure Git-based PHP extensions Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-EXT-install.yml.md Example configuration for installing PHP extensions from Git repositories, including dynamic reference resolution using shell code. ```yaml already_avail: [5.2] # Default for all PHP versions if no overwrite exists all: type: git git_url: https://github.com/phalcon/cphalcon git_ref: master # PHP 8.1 is overwriting the git_ref 8.1: type: git git_ref: v1.0.0 # PHP 8.0 is using a different git_ref dynamically with latest tag found # See the usage of supported shell code 8.0: type: git git_ref: $( git tag | sort -V | tail -1 ) ``` -------------------------------- ### Load custom PHP configuration Source: https://github.com/devilbox/docker-php-fpm/blob/master/README.md Example showing how to create a local configuration directory and mount it into the container to override PHP settings. ```shell # Create config directory to be mounted with dummy configuration mkdir config # Xdebug 2 echo "xdebug.enable = 1" > config/xdebug.ini # Xdebug 3 echo "xdebug.mode = debug" > config/xdebug.ini # Run container and mount it docker run -d -it \ -p 127.0.0.1:9000:9000 \ -v config:/etc/php-custom.d \ devilbox/php-fpm:7.2-prod ``` -------------------------------- ### Build prod image Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/abuser/README.md Optionally builds the prod image on top of the mods image to add startup configuration features. ```bash ARCH=linux/amd64 VERSION=8.1 make build STAGE=prod VERSION=${VERSION} ARCH=${ARCH} ``` -------------------------------- ### Create yq tool directory and files Source: https://github.com/devilbox/docker-php-fpm/blob/master/php_tools/README.md Commands to create the directory and empty files for a new PHP tool named yq. Run from the repository root. ```bash # Enter the php_tools directory cd php_tools/ # Create the yq directory mkdir yq # Create necessary empty files touch yq/install.yml touch yq/options.yml ``` -------------------------------- ### Start PHP-FPM container with NEW_UID and NEW_GID Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/syncronize-file-permissions.md Run the PHP-FPM container with NEW_UID and NEW_GID set to the host user's UID/GID (e.g., 1000). The container will perform usermod and groupmod before starting PHP-FPM, ensuring the process runs with the specified UID/GID. ```shell $ docker run -e NEW_UID=1000 -e NEW_GID=1000 -it devilbox/php-fpm:7.2-base [INFO] Changing user 'devilbox' uid to: 1000 root $ usermod -u 1000 devilbox [INFO] Changing group 'devilbox' gid to: 1000 root $ groupmod -g 1000 devilbox [INFO] Starting PHP 7.2.0 (fpm-fcgi) (built: Oct 30 2017 12:05:19) ``` -------------------------------- ### Define build dependencies with depends_build Source: https://github.com/devilbox/docker-php-fpm/blob/master/doc/contributor/PHP-EXT-options.yml.md Specify modules that must be built and installed before the current extension. ```yaml # Before building the current extension, it will be ensured that # igbinary and msgpack are build and installed beforehand. depends_build: - igbinary - msgpack ```