{"id":21664382,"url":"https://github.com/wayofdev/docker-php-base","last_synced_at":"2025-04-12T00:16:20.067Z","repository":{"id":40467084,"uuid":"439722135","full_name":"wayofdev/docker-php-base","owner":"wayofdev","description":"Foundational Docker PHP images with essential extensions. Multi-arch AMD64/ARM64 Alpine-based builds for CLI, FPM, and Supervisord. Optimized for production and development environments.","archived":false,"fork":false,"pushed_at":"2025-04-03T16:10:30.000Z","size":1658,"stargazers_count":7,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T00:16:04.383Z","etag":null,"topics":["alpine","ansible","cli","devops","docker","docker-image","docker-php","fpm","laravel","multi-arch","php","php-docker","supervisord"],"latest_commit_sha":null,"homepage":"https://wayof.dev","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wayofdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"wayofdev"}},"created_at":"2021-12-18T21:53:02.000Z","updated_at":"2025-02-27T19:12:11.000Z","dependencies_parsed_at":"2023-02-16T19:31:18.448Z","dependency_job_id":"ff9a48dd-e71c-4910-b259-4d0907004f91","html_url":"https://github.com/wayofdev/docker-php-base","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fdocker-php-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fdocker-php-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fdocker-php-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wayofdev%2Fdocker-php-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wayofdev","download_url":"https://codeload.github.com/wayofdev/docker-php-base/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497818,"owners_count":21113984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpine","ansible","cli","devops","docker","docker-image","docker-php","fpm","laravel","multi-arch","php","php-docker","supervisord"],"created_at":"2024-11-25T10:37:16.286Z","updated_at":"2025-04-12T00:16:20.037Z","avatar_url":"https://github.com/wayofdev.png","language":"Makefile","readme":"\u003cp align=\"center\"\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://wayof.dev\" target=\"_blank\"\u003e\n        \u003cpicture\u003e\n            \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-dark-mode-only.png\"\u003e\n            \u003cimg width=\"400\" src=\"https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-light-mode-only.png\" alt=\"WayOfDev Logo\"\u003e\n        \u003c/picture\u003e\n    \u003c/a\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://actions-badge.atrox.dev/wayofdev/docker-php-base/goto\"\u003e\u003cimg alt=\"Build Status\" src=\"https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fwayofdev%2Fdocker-php-base%2Fbadge\u0026style=flat-square\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/wayofdev/docker-php-base/tags\"\u003e\u003cimg src=\"https://img.shields.io/github/v/tag/wayofdev/docker-php-base?sort=semver\u0026style=flat-square\" alt=\"Latest Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://hub.docker.com/repository/docker/wayofdev/php-base\"\u003e\u003cimg alt=\"Docker Pulls\" src=\"https://img.shields.io/docker/pulls/wayofdev/php-base?style=flat-square\"\u003e\u003c/a\u003e\n\u003ca href=\"LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/github/license/wayofdev/docker-php-base.svg?style=flat-square\u0026color=blue\" alt=\"Software License\"/\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg alt=\"Commits since latest release\" src=\"https://img.shields.io/github/commits-since/wayofdev/docker-php-base/latest?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n# Docker Image: PHP Base\n\nThe `docker-php-base` project is a **system** for creating and maintaining **PHP Docker images**.\n\nIt uses **Ansible** to generate **Dockerfiles** for multiple PHP versions (7.4, 8.0, **8.1, 8.2, 8.3, 8.4**) and types (**CLI, FPM, Supervisord**) on **Alpine Linux**.\n\nThe project automates the build process using **GitHub Actions**, creating multi-architecture images (**AMD64** and **ARM64**) that are tested with [goss](https://github.com/goss-org/goss).\n\nImages come pre-configured with a wide array of PHP extensions and are designed to serve as a base for PHP applications in both **development** and **production** environments.\n\n\u003cbr\u003e\n\nIf you **like/use** this package, please consider ⭐️ **starring** it. Thanks!\n\n\u003cbr\u003e\n\n## 🚀 Features\n\n- **Multiple PHP Versions:** Supports PHP 7.4, 8.0, 8.1, 8.2, 8.3 and **8.4**.\n- **Various PHP Types:** Includes CLI, FPM, and Supervisord configurations.\n- **Alpine-based:** Lightweight images built on Alpine Linux.\n- **Pre-configured Extensions:** Comes with a wide range of pre-installed PHP extensions.\n- **Customizable Settings:** Easily adjustable PHP and OPcache settings.\n- **Multi-architecture Support:** Built for both AMD64 and ARM64 architectures.\n- **Automated Builds:** Utilizes GitHub Actions for continuous integration and delivery.\n- **Comprehensive Testing:** Implements dgoss for thorough Docker image testing.\n- **Ansible-based Generation:** Leverages Ansible for flexible and maintainable Dockerfile generation.\n- **Security Focused:** Includes Docker Scout scans for vulnerability checks.\n\n\u003cbr\u003e\n\n## 🛠 Technology Stack\n\n- **Ansible:** For generating Dockerfiles and configurations.\n- **Docker:** Base technology for containerization.\n- **GitHub Actions:** CI/CD pipeline for automated building, testing, and publishing.\n- **dgoss:** For Docker image testing.\n- **Alpine Linux:** Base OS for the Docker images.\n- **PHP:** Core language with multiple versions (7.4, 8.0, 8.1, 8.2, 8.3, 8.4).\n\n\u003cbr\u003e\n\n## 📦 Pre-installed PHP Extensions\n\nThe images come with a variety of pre-installed PHP extensions:\n\n| Extension                                                    | Description                                                                      | Type   |\n|--------------------------------------------------------------|----------------------------------------------------------------------------------|--------|\n| [intl](https://www.php.net/manual/en/book.intl.php)          | Internationalization functions                                                   | native |\n| [pcntl](https://www.php.net/manual/en/book.pcntl.php)        | Process control                                                                  | native |\n| [sockets](https://www.php.net/manual/en/book.sockets.php)    | Socket communication functions                                                   | native |\n| [pdo_pgsql](https://www.php.net/manual/en/ref.pdo-pgsql.php) | PostgreSQL functions                                                             | native |\n| [pdo_mysql](https://www.php.net/manual/en/ref.pdo-mysql.php) | MySQL functions                                                                  | native |\n| [opcache](https://www.php.net/manual/en/book.opcache.php)    | Improves PHP performance by storing precompiled script bytecode in shared memory | native |\n| [zip](https://www.php.net/manual/en/book.zip.php)            | Read/write functions for ZIP archives                                            | native |\n| [bcmath](https://www.php.net/manual/en/book.bc.php)          | For arbitrary precision mathematics                                              | native |\n| [exif](https://www.php.net/manual/en/book.exif.php)          | Exchangeable image information                                                   | native |\n| [gd](https://www.php.net/manual/en/book.image.php)           | Image processing and manipulation library                                        | native |\n| [redis](https://pecl.php.net/package/redis)                  | Functions for interfacing with Redis                                             | pecl   |\n| [memcached](https://pecl.php.net/package/memcached)          | Functions for interfacing with Memcached                                         | pecl   |\n| [decimal](https://pecl.php.net/package/decimal)              | Arbitrary precision floating-point decimal                                       | pecl   |\n| [amqp](https://pecl.php.net/package/amqp)                    | Advanced Message Queuing Protocol (AMQP) library                                 | pecl   |\n| [yaml](https://pecl.php.net/package/yaml)                    | YAML library                                                                     | pecl   |\n| [grpc](https://pecl.php.net/package/grpc)                    | gRPC library                                                                     | pecl   |\n| [protobuf](https://pecl.php.net/package/protobuf)            | Protocol Buffers library                                                         | pecl   |\n\n\u003cbr\u003e\n\n## 🚀 Usage\n\nThe PHP base images are available on both Docker Hub and GitHub Container Registry (ghcr.io). You can pull the images using either of the following methods:\n\n### → Docker Hub\n\n```bash\ndocker pull wayofdev/php-base:8.3-fpm-alpine-latest\n```\n\n### → GitHub Container Registry\n\n```bash\ndocker pull ghcr.io/wayofdev/docker-php-base:8.3-fpm-alpine-latest\n```\n\nReplace `8.3-fpm-alpine-latest` with your desired PHP version, type, and tag.\n\n### → Available Image Variants\n\nThe images are available in various combinations of PHP versions, types, and architectures:\n\n- **PHP Versions:** 8.1, 8.2, 8.3, 8.4\n- **Types:** cli, fpm, supervisord\n- **Architectures:** amd64, arm64\n\n#### Examples\n\n```bash\n# PHP 8.1 CLI\ndocker pull wayofdev/php-base:8.1-cli-alpine-latest\n\n# PHP 8.2 FPM\ndocker pull wayofdev/php-base:8.2-fpm-alpine-latest\n\n# PHP 8.3 with Supervisord\ndocker pull wayofdev/php-base:8.3-supervisord-alpine-latest\n```\n\nFor a complete list of available tags, please refer to the [Docker Hub Tags](https://hub.docker.com/r/wayofdev/php-base/tags) or [GitHub Container Registry Packages](https://github.com/wayofdev/docker-php-base/pkgs/container/docker-php-base) page.\n\n### → Using in Dockerfile\n\nTo use these images as a base for your own Dockerfile:\n\n```dockerfile\n# From Docker Hub\nFROM wayofdev/php-base:8.3-fpm-alpine-latest\n\n# Or from GitHub Container Registry\n# FROM ghcr.io/wayofdev/docker-php-base:8.3-fpm-alpine-latest\n\n# Your additional Dockerfile instructions here\n# ...\n```\n\n\u003cbr\u003e\n\n## 🔨 Development\n\nThis project uses a set of tools for development and testing. The `Makefile` provides various commands to streamline the development process.\n\n### → Requirements\n\n- Docker\n- Make\n- Ansible\n- goss and dgoss for testing\n\n### → Setting Up the Development Environment\n\nClone the repository:\n\n```bash\ngit clone git@github.com:wayofdev/docker-php-base.git \u0026\u0026 \\\ncd docker-php-base\n```\n\n### → Generating Dockerfiles\n\nAnsible is used to generate Dockerfiles and configurations. To generate distributable Dockerfiles from Jinja template source code:\n\n```bash\nmake generate\n```\n\n### → Building Images\n\n- Build the default image:\n\n  ```bash\n  make build\n  ```\n\n  This command builds the image specified by the `IMAGE_TEMPLATE` variable in the Makefile. By default, it's set to `8.3-fpm-alpine`.\n\n- Build a specific image:\n\n  ```bash\n  make build IMAGE_TEMPLATE=\"8.3-fpm-alpine\"\n  ```\n\n  Replace `8.3-fpm-alpine` with your desired PHP version, type, and OS.\n\n- Build all images:\n\n  ```bash\n  make build IMAGE_TEMPLATE=\"8.1-cli-alpine\"\n  make build IMAGE_TEMPLATE=\"8.1-fpm-alpine\"\n  make build IMAGE_TEMPLATE=\"8.1-supervisord-alpine\"\n  make build IMAGE_TEMPLATE=\"8.2-cli-alpine\"\n  make build IMAGE_TEMPLATE=\"8.2-fpm-alpine\"\n  make build IMAGE_TEMPLATE=\"8.2-supervisord-alpine\"\n  make build IMAGE_TEMPLATE=\"8.3-cli-alpine\"\n  make build IMAGE_TEMPLATE=\"8.3-fpm-alpine\"\n  make build IMAGE_TEMPLATE=\"8.3-supervisord-alpine\"\n  make build IMAGE_TEMPLATE=\"8.4-cli-alpine\"\n  make build IMAGE_TEMPLATE=\"8.4-fpm-alpine\"\n  make build IMAGE_TEMPLATE=\"8.4-supervisord-alpine\"\n  ```\n\n  These commands will build all supported image variants.\n\n\u003cbr\u003e\n\n## 🔧 Configuration\n\nAnsible is used to generate distribution files. To add or remove PHP extensions, or configure the project, you can modify the [src/group_vars/base.yml](https://github.com/wayofdev/docker-php-base/blob/master/src/group_vars/base.yml) file.\n\n### → Default .ini settings for PHP\n\nYou can adjust the following PHP and OPcache settings in the `group_vars/base.yml` file:\n\n```yaml\nsettings_opcache_ini:\n  php_opcache_enable: 1\n  php_opcache_enable_cli: 1\n\nsettings_php_ini:\n  php_timezone: \"UTC\"\n  php_post_max_size: \"16M\"\n  php_memory_limit: \"256M\"\n```\n\n### → PHP Extensions\n\nYou can enable or disable PHP extensions by modifying the following sections in the `group_vars/base.yml` file:\n\n```yaml\next_native_enabled:\n  - intl\n  - pcntl\n  - sockets\n  - pdo_mysql\n  - pdo_pgsql\n  - OPcache\n  - zip\n  - bcmath\n  - exif\n  - gd\n\next_pecl_enabled:\n  - redis\n  - memcached\n  - decimal\n  - amqp\n  - yaml\n  - grpc\n  - protobuf\n```\n\nTo add a new extension, simply add it to the appropriate list. To remove an extension, delete it from the list.\n\nAfter making changes to the `group_vars/base.yml` file, you need to regenerate the Dockerfiles:\n\n```bash\nmake generate\n```\n\nThis command will use Ansible to process the updated configuration and generate new Dockerfiles with your custom settings.\n\n\u003cbr\u003e\n\n## 🧪 Testing\n\nThis project uses a testing approach to ensure the quality and functionality of the Docker images. The primary testing tool is [dgoss](https://github.com/aelsabbahy/goss/tree/master/extras/dgoss), which allows for testing Docker containers.\n\n### → Running Tests\n\nYou can run tests using the following commands:\n\n- Test the default image:\n\n  ```bash\n  make test\n  ```\n\n  This command tests the image specified by the `IMAGE_TEMPLATE` variable in the Makefile (default is `8.3-fpm-alpine`).\n\n- Test a specific image:\n\n  ```bash\n  make test IMAGE_TEMPLATE=\"8.3-fpm-alpine\"\n  ```\n\n  Replace `8.3-fpm-alpine` with your desired PHP version, type, and OS.\n\n- Test all images:\n\n  ```bash\n  make test IMAGE_TEMPLATE=\"8.1-cli-alpine\"\n  make test IMAGE_TEMPLATE=\"8.1-fpm-alpine\"\n  make test IMAGE_TEMPLATE=\"8.1-supervisord-alpine\"\n  make test IMAGE_TEMPLATE=\"8.2-cli-alpine\"\n  make test IMAGE_TEMPLATE=\"8.2-fpm-alpine\"\n  make test IMAGE_TEMPLATE=\"8.2-supervisord-alpine\"\n  make test IMAGE_TEMPLATE=\"8.3-cli-alpine\"\n  make test IMAGE_TEMPLATE=\"8.3-fpm-alpine\"\n  make test IMAGE_TEMPLATE=\"8.3-supervisord-alpine\"\n  make test IMAGE_TEMPLATE=\"8.4-cli-alpine\"\n  make test IMAGE_TEMPLATE=\"8.4-fpm-alpine\"\n  make test IMAGE_TEMPLATE=\"8.4-supervisord-alpine\"\n  ```\n\n### → Test Configuration\n\nThe test configurations are defined in `goss.yaml` files, which are generated for each image variant. These files specify the tests to be run, including:\n\n- File existence and permissions\n- Process checks\n- Port availability\n- Package installations\n- Command outputs\n- PHP extension availability\n\n### → Test Process\n\nWhen you run the `make test` command, the following steps occur:\n\n1. The specified Docker image is built (if not already present).\n2. dgoss runs the tests defined in the `goss.yaml` file against the Docker container.\n3. The test results are displayed in the console.\n\n\u003cbr\u003e\n\n## 🔒 Security Policy\n\nThis project has a [security policy](.github/SECURITY.md).\n\n\u003cbr\u003e\n\n## 🙌 Want to Contribute?\n\nThank you for considering contributing to the wayofdev community! We are open to all kinds of contributions. If you want to:\n\n- 🤔 [Suggest a feature](https://github.com/wayofdev/docker-php-base/issues/new?assignees=\u0026labels=type%3A+enhancement\u0026projects=\u0026template=2-feature-request.yml\u0026title=%5BFeature%5D%3A+)\n- 🐛 [Report an issue](https://github.com/wayofdev/docker-php-base/issues/new?assignees=\u0026labels=type%3A+documentation%2Ctype%3A+maintenance\u0026projects=\u0026template=1-bug-report.yml\u0026title=%5BBug%5D%3A+)\n- 📖 [Improve documentation](https://github.com/wayofdev/docker-php-base/issues/new?assignees=\u0026labels=type%3A+documentation%2Ctype%3A+maintenance\u0026projects=\u0026template=4-docs-bug-report.yml\u0026title=%5BDocs%5D%3A+)\n- 👨‍💻 [Contribute to the code](./.github/CONTRIBUTING.md)\n\nYou are more than welcome. Before contributing, kindly check our [contribution guidelines](.github/CONTRIBUTING.md).\n\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge)](https://conventionalcommits.org)\n\n\u003cbr\u003e\n\n## 🫡 Contributors\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"https://github.com/wayofdev/docker-php-base/graphs/contributors\"\u003e\n\u003cimg align=\"left\" src=\"https://img.shields.io/github/contributors-anon/wayofdev/docker-php-base?style=for-the-badge\" alt=\"Contributors Badge\"/\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003c/p\u003e\n\n## 🌐 Social Links\n\n- **Twitter:** Follow our organization [@wayofdev](https://twitter.com/intent/follow?screen_name=wayofdev) and the author [@wlotyp](https://twitter.com/intent/follow?screen_name=wlotyp).\n- **Discord:** Join our community on [Discord](https://discord.gg/CE3TcCC5vr).\n\n\u003cbr\u003e\n\n## ⚖️ License\n\n[![Licence](https://img.shields.io/github/license/wayofdev/docker-php-base?style=for-the-badge\u0026color=blue)](./LICENSE.md)\n\n\u003cbr\u003e\n","funding_links":["https://github.com/sponsors/wayofdev"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayofdev%2Fdocker-php-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwayofdev%2Fdocker-php-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwayofdev%2Fdocker-php-base/lists"}