|
| 1 | +<br> |
| 2 | + |
| 3 | +<div align="center"> |
| 4 | +<img width="456" src="https://raw.githubusercontent.com/wayofdev/docker-php-base/master/assets/logo.gh-light-mode-only.png#gh-light-mode-only"> |
| 5 | +<img width="456" src="https://raw.githubusercontent.com/wayofdev/docker-php-base/master/assets/logo.gh-dark-mode-only.png#gh-dark-mode-only"> |
| 6 | +</div> |
| 7 | + |
| 8 | +<br> |
| 9 | + |
| 10 | +<br> |
| 11 | + |
| 12 | +<div align="center"> |
| 13 | +<a href="https://actions-badge.atrox.dev/wayofdev/docker-php-base/goto"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fwayofdev%2Fdocker-php-base%2Fbadge&style=flat-square"/></a> |
| 14 | +<a href="https://github.com/wayofdev/docker-php-base/tags"><img src="https://img.shields.io/github/v/tag/wayofdev/docker-php-base?sort=semver&style=flat-square" alt="Latest Version"></a> |
| 15 | +<a href="https://hub.docker.com/repository/docker/wayofdev/postgres"><img alt="Docker Pulls" src="https://img.shields.io/docker/pulls/wayofdev/postgres?style=flat-square"></a> |
| 16 | +<a href="LICENSE"><img src="https://img.shields.io/github/license/wayofdev/docker-php-base.svg?style=flat-square&color=blue" alt="Software License"/></a> |
| 17 | +<a href="#"><img alt="Commits since latest release" src="https://img.shields.io/github/commits-since/wayofdev/docker-php-base/latest?style=flat-square"></a> |
| 18 | +</div> |
| 19 | +<br> |
| 20 | + |
| 21 | +# Docker Image: PHP Base |
| 22 | + |
| 23 | +Repository contains dist folder with generated basic PHP images and source code, written on Ansible, to generate them. Is used together with other WOD images, to create local development environment for our projects. |
| 24 | + |
| 25 | +Enabled extensions by default: |
| 26 | + |
| 27 | +| Extension | Description | Type | |
| 28 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------ | |
| 29 | +| [intl](https://www.php.net/manual/en/book.intl.php) | Internationalization functions | native | |
| 30 | +| [pcntl](https://www.php.net/manual/en/book.pcntl.php) | Process control | native | |
| 31 | +| [sockets](https://www.php.net/manual/en/book.sockets.php) | Socket communication functions | native | |
| 32 | +| [pdo_pgsql](https://www.php.net/manual/en/ref.pdo-pgsql.php) | PostgreSQL functions | native | |
| 33 | +| [opcache](https://www.php.net/manual/en/book.opcache.php) | OPcache improves PHP performance by storing precompiled script bytecode in shared memory | native | |
| 34 | +| [zip](https://www.php.net/manual/en/book.zip.php) | Read/write functions for ZIP archives | native | |
| 35 | +| [bcmath](https://www.php.net/manual/en/book.bc.php) | For arbitrary precision mathematics | native | |
| 36 | +| [redis](https://pecl.php.net/package/redis) | Functions for interfacing with Redis | pecl | |
| 37 | +| [decimal](https://pecl.php.net/package/decimal) | Arbitrary precision floating-point decimal | pecl | |
| 38 | + |
| 39 | +<br> |
| 40 | + |
| 41 | +If you **like/use** this repository, please consider **starring** it. Thanks! |
| 42 | + |
| 43 | +<br> |
| 44 | + |
| 45 | +## 🔧 Configuration |
| 46 | + |
| 47 | +Ansible is used to generate distribution files, to add or remove PHP extensions, or configure project, see [group_vars/base.yml](https://github.com/wayofdev/docker-php-base/blob/master/src/group_vars/base.yml) |
| 48 | + |
| 49 | +**Default .ini settings for PHP:** |
| 50 | + |
| 51 | +```yaml |
| 52 | +settings_opcache_ini: |
| 53 | + php_opcache_enable: 1 |
| 54 | + php_opcache_enable_cli: 1 |
| 55 | + |
| 56 | +settings_php_ini: |
| 57 | + php_timezone: "UTC" |
| 58 | + php_post_max_size: "16M" |
| 59 | + php_memory_limit: "256M" |
| 60 | +``` |
| 61 | +
|
| 62 | +**Default extension configuration:** |
| 63 | +
|
| 64 | +```yaml |
| 65 | +ext_native_enabled: |
| 66 | + - intl |
| 67 | + - pcntl |
| 68 | + - sockets |
| 69 | + - pdo_pgsql |
| 70 | + - OPcache |
| 71 | + - zip |
| 72 | + - bcmath |
| 73 | + |
| 74 | +ext_pecl_enabled: |
| 75 | + - redis |
| 76 | + - decimal |
| 77 | + |
| 78 | +ext_pecl_versions: |
| 79 | + redis: "5.3.7" |
| 80 | + decimal: "1.4.0" |
| 81 | +``` |
| 82 | +
|
| 83 | +<br> |
| 84 | +
|
| 85 | +To generate dist files use ansible command: |
| 86 | +
|
| 87 | +```bash |
| 88 | +$ make generate |
| 89 | +``` |
| 90 | + |
| 91 | +<br> |
| 92 | + |
| 93 | +## ⚙️ Development |
| 94 | + |
| 95 | +To install dependencies and start development you can check contents of our `Makefile` |
| 96 | + |
| 97 | +### → Requirments |
| 98 | + |
| 99 | +For testing purposes we use **goss** and **dgoss**, follow installation instructions on [their official README](https://github.com/aelsabbahy/goss/blob/master/extras/dgoss/README.md) |
| 100 | + |
| 101 | +<br> |
| 102 | + |
| 103 | +### → Building locally |
| 104 | + |
| 105 | +Generating distributable Dockerfiles from yaml source code: |
| 106 | + |
| 107 | +```bash |
| 108 | +$ make generate |
| 109 | +``` |
| 110 | + |
| 111 | +<br> |
| 112 | + |
| 113 | +Building default image: |
| 114 | + |
| 115 | +```bash |
| 116 | +$ git clone git@github.com:wayofdev/docker-php-base.git |
| 117 | +$ make build |
| 118 | +``` |
| 119 | + |
| 120 | +To **build** image, **test** it and then **clean** temporary files run: |
| 121 | + |
| 122 | +```bash |
| 123 | +$ make |
| 124 | +``` |
| 125 | + |
| 126 | +Building all images: |
| 127 | + |
| 128 | +```bash |
| 129 | +$ make build TEMPLATE="7.4-cli-alpine" |
| 130 | +$ make build TEMPLATE="7.4-fpm-alpine" |
| 131 | +$ make build TEMPLATE="8.0-cli-alpine" |
| 132 | +$ make build TEMPLATE="8.0-fpm-alpine" |
| 133 | +$ make build TEMPLATE="8.1-cli-alpine" |
| 134 | +$ make build TEMPLATE="8.1-fpm-alpine" |
| 135 | +``` |
| 136 | + |
| 137 | +<br> |
| 138 | + |
| 139 | +## 🧪 Testing |
| 140 | + |
| 141 | +You can check `Makefile` to get full list of commands for local testing. For testing you can use these comands to test whole role or separate tasks: |
| 142 | + |
| 143 | +Testing default image: |
| 144 | + |
| 145 | +```bash |
| 146 | +$ make test |
| 147 | +``` |
| 148 | + |
| 149 | +To test all images: |
| 150 | + |
| 151 | +```bash |
| 152 | +$ make test TEMPLATE="7.4-cli-alpine" |
| 153 | +$ make test TEMPLATE="7.4-fpm-alpine" |
| 154 | +$ make test TEMPLATE="8.0-cli-alpine" |
| 155 | +$ make test TEMPLATE="8.0-fpm-alpine" |
| 156 | +$ make test TEMPLATE="8.1-cli-alpine" |
| 157 | +$ make test TEMPLATE="8.1-fpm-alpine" |
| 158 | +``` |
| 159 | + |
| 160 | +<br> |
| 161 | + |
| 162 | +### → Code quality tools |
| 163 | + |
| 164 | +Run **yamllint** to validate all yaml files in project: |
| 165 | + |
| 166 | +```bash |
| 167 | +$ make lint |
| 168 | +``` |
| 169 | + |
| 170 | +Run hadolint to validate created Dockerfiles: |
| 171 | + |
| 172 | +```bash |
| 173 | +$ make hadolint |
| 174 | +``` |
| 175 | + |
| 176 | +<br> |
| 177 | + |
| 178 | +## 🤝 License |
| 179 | + |
| 180 | +[](./LICENSE) |
| 181 | + |
| 182 | +<br> |
| 183 | + |
| 184 | +## 🙆🏼♂️ Author Information |
| 185 | + |
| 186 | +This repository was created in **2022** by [lotyp / wayofdev](https://github.com/wayofdev). |
| 187 | + |
| 188 | +<br> |
| 189 | + |
| 190 | +## 🫡 Contributors |
| 191 | + |
| 192 | +<img align="left" src="https://img.shields.io/github/contributors-anon/wayofdev/docker-php-base?style=for-the-badge"/> |
| 193 | + |
| 194 | +<a href="https://github.com/wayofdev/docker-nginx/graphs/contributors"> |
| 195 | + <img src="https://opencollective.com/wod/contributors.svg?width=890&button=false"> |
| 196 | +</a> |
| 197 | + |
| 198 | +<br> |
0 commit comments