Skip to content

Commit 676dabb

Browse files
committed
Separate build and test stages (with bake)
1 parent 9df685f commit 676dabb

File tree

4 files changed

+40
-41
lines changed

4 files changed

+40
-41
lines changed

.github/workflows/workflow.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
uses: docker/setup-buildx-action@v1
2525
- name: Checkout
2626
uses: actions/checkout@v1
27-
- name: Build
27+
- name: Build locally
2828
run: |
2929
PHP_VERSION="${{ matrix.php_version }}"
3030
docker buildx bake --load \
31-
--platform=${PLATFORM:$(uname -p)}} \
31+
--set "*.platform=$(uname -p)" \
3232
php${PHP_VERSION//.}-${{ matrix.variant }}
3333
docker images --filter=reference=thecodingmachine/php
3434
- name: Login to DockerHub
@@ -38,14 +38,11 @@ jobs:
3838
with:
3939
username: ${{ secrets.DOCKERHUB_USERNAME }}
4040
password: ${{ secrets.DOCKERHUB_TOKEN }}
41-
- name: Release
41+
- name: Build and push to repository
4242
# Merge ~ push.
4343
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
4444
run: |
4545
PHP_VERSION="${{ matrix.php_version }}"
4646
PHP_PATCH_VERSION=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-${BRANCH_VARIANT} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
4747
TAG=${PHP_PATCH_VERSION} docker buildx bake --push \
48-
--cache-from=type=local,src=/tmp/buildx-cache \
49-
--cache-to=type=local,dest=/tmp/buildx-cache \
50-
--platform=${PLATFORM:$(uname -p)}} \
5148
php${PHP_VERSION//.}-${{ matrix.variant }}

Makefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
SHELL=/bin/bash
2+
13
blueprint: ## Generate all blueprints file
24
@if ! type orbit >/dev/null 2>&1; then echo "Missing orbit dependency, please install from https://github.com/gulien/orbit/"; exit 1; fi
35
orbit run generate
@@ -8,21 +10,21 @@ _test-prerequisites: blueprint
810
docker pull ubuntu:20.04
911

1012
test-quick: ## Test 8.0 and 8.1 quickly
11-
PHP_VERSION=8.0 VARIANT=cli $(MAKE) _test-version
12-
PHP_VERSION=8.1 VARIANT=cli $(MAKE) _test-version
13+
VERSION=8.0 VARIANT=cli $(MAKE) _test-version
14+
VERSION=8.1 VARIANT=cli $(MAKE) _test-version
1315

1416
test-8.1: ## Test php8.1 build only
15-
PHP_VERSION=8.1 VARIANT=cli $(MAKE) _test-version
16-
PHP_VERSION=8.1 VARIANT=apache $(MAKE) _test-version
17+
VERSION=8.1 VARIANT=cli $(MAKE) _test-version
18+
VERSION=8.1 VARIANT=apache $(MAKE) _test-version
1719

1820
test-8.0: ## Test php8.0 build only
19-
PHP_VERSION=8.0 VARIANT=cli $(MAKE) _test-version
20-
PHP_VERSION=8.0 VARIANT=apache $(MAKE) _test-version
21+
VERSION=8.0 VARIANT=cli $(MAKE) _test-version
22+
VERSION=8.0 VARIANT=apache $(MAKE) _test-version
2123

2224
_test-version: _test-prerequisites ## Test php build for VERSION="" and VARIANT=""
2325
docker buildx bake --load \
24-
--platform=${PLATFORM:$(uname -p)}} \
25-
php${VERSION//.}-cli
26+
--set "*.platform=$$(uname -p)" \
27+
php$${VERSION//.}-cli
2628
PHP_VERSION="$(VERSION)" BRANCH=v4 VARIANT=cli ./test-image.sh || (notify-send -u critical "Tests failed ($(VERSION)-$(VARIANT))" && exit 1)
2729
notify-send -u critical "Tests passed with success ($(VERSION)-$(VARIANT))"
2830

README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,26 @@ These images are based on the [official PHP image](https://hub.docker.com/_/php/
132132
Example with CLI:
133133

134134
```bash
135-
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app thecodingmachine/php:8.0-v4-cli php your-script.php
135+
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app thecodingmachine/php:8.1-v4-cli php your-script.php
136136
```
137137

138138
Example with Apache:
139139

140140
```bash
141-
$ docker run -p 80:80 --rm --name my-apache-php-app -v "$PWD":/var/www/html thecodingmachine/php:8.0-v4-apache
141+
$ docker run -p 80:80 --rm --name my-apache-php-app -v "$PWD":/var/www/html thecodingmachine/php:8.1-v4-apache
142142
```
143143

144144
Example with PHP-FPM:
145145

146146
```bash
147-
$ docker run -p 9000:9000 --rm --name my-php-fpm -v "$PWD":/var/www/html thecodingmachine/php:8.0-v4-fpm
147+
$ docker run -p 9000:9000 --rm --name my-php-fpm -v "$PWD":/var/www/html thecodingmachine/php:8.1-v4-fpm
148148
```
149149

150150
Example with Apache + Node 14.x in a Dockerfile:
151151

152152
**Dockerfile**
153153
```Dockerfile
154-
FROM thecodingmachine/php:8.0-v4-apache-node14
154+
FROM thecodingmachine/php:8.1-v4-apache-node14
155155

156156
COPY src/ /var/www/html/
157157
RUN composer install
@@ -165,7 +165,7 @@ This image comes with 2 "types": the *slim* and the **fat** image.
165165

166166
These extensions are enabled by default in slim image: `calendar` `ctype` `curl` `date` `dom` `exif` `fileinfo` `filter` `ftp` `gettext` `iconv` `json` `mbstring` `opcache` `openssl` `pcntl` `pcre` `PDO` `Phar` `posix` `readline` `shmop` `Reflection` `session` `shmop` `SimpleXML` `sockets` `sodium` `SPL` `sysvmsg` `sysvsem` `sysvshm` `tokenizer` `xml` `xmlreader` `xmlwriter` `xsl` `zip`
167167

168-
This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.0-v4-slim-cli php -m`
168+
This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.1-v4-slim-cli php -m`
169169

170170
The slim image provides a simple way to install the other extensions. You would typically use the "slim" image in a `Dockerfile` when building your own custom image.
171171

@@ -179,7 +179,7 @@ Below is a list of extensions available in this image:
179179

180180
**Available (can be enabled using environment variables):** `amqp` `ast` `bcmath` `blackfire` `bz2` `dba` `ds` `enchant` `ev` `event` `exif` `mailparse` `msgpack` `gd` `gettext` `gmp` `gnupg` `grpc` `igbinary` `imagick` `imap` `intl` `ldap` `mcrypt` `memcached` `mongodb` `pcov` `pdo_dblib` `pdo_pgsql` `pdo_sqlite` `pgsql` `pspell` `shmop` `snmp` `sockets` `sqlite3` `swoole` `tidy` `uploadprogress` `uuid` `weakref(-beta)` `xdebug` `xmlrpc` `xsl` `yaml`
181181

182-
This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.0-v4-cli php -m`
182+
This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.1-v4-cli php -m`
183183

184184
**Note**:
185185

@@ -199,7 +199,7 @@ For instance:
199199
version: '3'
200200
services:
201201
my_app:
202-
image: thecodingmachine/php:8.0-v4-apache-node16
202+
image: thecodingmachine/php:8.1-v4-apache-node16
203203
environment:
204204
# Enable the PostgreSQL extension
205205
PHP_EXTENSION_PGSQL: 1
@@ -219,7 +219,7 @@ If you are using the slim image, you can automatically compile the extensions us
219219

220220
```Dockerfile
221221
ARG PHP_EXTENSIONS="apcu mysqli pdo_mysql redis soap"
222-
FROM thecodingmachine/php:8.0-v4-slim-apache
222+
FROM thecodingmachine/php:8.1-v4-slim-apache
223223
# The build will automatically trigger the download and compilation
224224
# of the extensions (thanks to a ONBUILD hook in the slim image)
225225
```
@@ -235,7 +235,7 @@ first FROM):
235235
# The PHP_EXTENSIONS ARG will apply to the "slim" image
236236
ARG PHP_EXTENSIONS="apcu mysqli pdo_mysql soap"
237237
238-
FROM thecodingmachine/php:8.0-v4-apache-node16 AS builder
238+
FROM thecodingmachine/php:8.1-v4-apache-node16 AS builder
239239
240240
COPY --chown=docker:docker sources/web .
241241
RUN composer install &&\
@@ -256,7 +256,7 @@ not contain Node, and contains only required extensions.
256256

257257
## Setting parameters in php.ini
258258

259-
By default, the base `php.ini` file used is the [*development* php.ini](https://github.com/php/php-src/blob/PHP-8.0/php.ini-development) file that comes with PHP.
259+
By default, the base `php.ini` file used is the [*development* php.ini](https://github.com/php/php-src/blob/PHP-8.1/php.ini-development) file that comes with PHP.
260260

261261
You can use the production `php.ini` file using the `TEMPLATE_PHP_INI` environment variable:
262262

@@ -271,7 +271,7 @@ You can override parameters in `php.ini` using the PHP_INI_XXX environment varia
271271
version: '3'
272272
services:
273273
my_app:
274-
image: thecodingmachine/php:8.0-v4-apache-node16
274+
image: thecodingmachine/php:8.1-v4-apache-node16
275275
environment:
276276
# set the parameter memory_limit=1g
277277
PHP_INI_MEMORY_LIMIT: 1g
@@ -333,7 +333,7 @@ For instance:
333333
version: '3'
334334
services:
335335
my_app:
336-
image: thecodingmachine/php:8.0-v4-apache-node16
336+
image: thecodingmachine/php:8.1-v4-apache-node16
337337
environment:
338338
# Enable the DAV extension for Apache
339339
APACHE_EXTENSION_DAV: 1
@@ -351,7 +351,7 @@ APACHE_EXTENSIONS="dav ssl"
351351

352352
**Apache modules available:** `access_compat` `actions` `alias` `allowmethods` `asis` `auth_basic` `auth_digest` `auth_form` `authn_anon` `authn_core` `authn_dbd` `authn_dbm` `authn_file` `authn_socache` `authnz_fcgi` `authnz_ldap` `authz_core` `authz_dbd` `authz_dbm` `authz_groupfile` `authz_host` `authz_owner` `authz_user` `autoindex` `brotli` `buffer` `cache` `cache_disk` `cache_socache` `cern_meta` `cgi` `cgid` `charset_lite` `data` `dav` `dav_fs` `dav_lock` `dbd` `deflate` `dialup` `dir` `dump_io` `echo` `env` `ext_filter` `expires` `file_cache` `filter` `headers` `heartbeat` `heartmonitor` `http2` `ident` `imagemap` `include` `info` `lbmethod_bybusyness` `lbmethod_byrequests` `lbmethod_bytraffic` `lbmethod_heartbeat` `ldap` `log_debug` `log_forensic` `lua` `macro` `md` `mime` `mime_magic` `mpm_event` `mpm_prefork` `mpm_worker` `negotiation` `php8.0 (depend of your active version)` `proxy` `proxy_ajp` `proxy_balancer` `proxy_connect` `proxy_express` `proxy_fcgi` `proxy_fdpass` `proxy_ftp` `proxy_hcheck` `proxy_html` `proxy_http` `proxy_http2` `proxy_scgi` `proxy_wstunnel` `ratelimit` `reflector` `remoteip` `reqtimeout` `request` `rewrite` `sed` `session` `session_cookie` `session_crypto` `session_dbd` `setenvif` `slotmem_plain` `slotmem_shm` `socache_dbm` `socache_memcache` `socache_redis` `socache_shmcb` `speling` `ssl` `status` `substitute` `suexec` `unique_id` `userdir` `usertrack` `vhost_alias` `xml2enc`
353353

354-
This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.0-v4-slim-apache a2enmod`
354+
This list can be outdated, you can verify by executing : `docker run --rm -it thecodingmachine/php:8.1-v4-slim-apache a2enmod`
355355

356356

357357
## Debugging
@@ -386,7 +386,7 @@ If you use the *slim* images, you can install a NodeJS version with a simple ARG
386386

387387
```Dockerfile
388388
ARG NODE_VERSION=14
389-
FROM thecodingmachine/php:8.0-v4-slim-apache
389+
FROM thecodingmachine/php:8.1-v4-slim-apache
390390
# The build will automatically trigger the download of Node 14
391391
# (thanks to a ONBUILD hook in the slim image)
392392
```
@@ -439,7 +439,7 @@ This can be done easily:
439439

440440
**Dockerfile**
441441
```Dockerfile
442-
FROM thecodingmachine/php:8.0-v4-apache
442+
FROM thecodingmachine/php:8.1-v4-apache
443443
444444
# ...
445445
@@ -483,7 +483,7 @@ a single argument before the "FROM" clause in your Dockerfile:
483483

484484
```Dockerfile
485485
ARG INSTALL_CRON=1
486-
FROM thecodingmachine/php:8.0-v4-slim-apache
486+
FROM thecodingmachine/php:8.1-v4-slim-apache
487487
# The build triggers automatically the installation of Cron
488488
```
489489

@@ -536,20 +536,20 @@ If such a file is mounted in the image, it will be executed on container startup
536536

537537
```bash
538538
docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp \
539-
-v $PWD/my-startup-script.sh:/etc/container/startup.sh thecodingmachine/php:8.0-v4-cli php your-script.php
539+
-v $PWD/my-startup-script.sh:/etc/container/startup.sh thecodingmachine/php:8.1-v4-cli php your-script.php
540540
```
541541

542542
## Using the CLI variant
543543

544-
The CLI images (thecodingmachine/php:8.0-v4-cli) expect a command to be passed in parameter.
544+
The CLI images (thecodingmachine/php:8.1-v4-cli) expect a command to be passed in parameter.
545545
You should override the Docker "command".
546546

547547
Important! You should not override the Docker "entrypoint".
548548

549549
**Usage in a Dockerfile:**
550550

551551
```Dockerfile
552-
FROM thecodingmachine/php:8.0-v4-cli
552+
FROM thecodingmachine/php:8.1-v4-cli
553553
554554
CMD ["php", "myprogram.php", "some_param"]
555555
```
@@ -561,7 +561,7 @@ CMD ["php", "myprogram.php", "some_param"]
561561
version: '3'
562562
services:
563563
my_app:
564-
image: thecodingmachine/php:8.0-v4-cli
564+
image: thecodingmachine/php:8.1-v4-cli
565565
command: php myprogram.php some_param
566566
```
567567

@@ -581,7 +581,7 @@ This option is the easiest way to go if you are using the image on a development
581581
version: '3'
582582
services:
583583
my_app:
584-
image: thecodingmachine/php:8.0-v4-apache-node16
584+
image: thecodingmachine/php:8.1-v4-apache-node16
585585
volumes:
586586
- ~/.ssh:/home/docker/.ssh
587587
```
@@ -602,7 +602,7 @@ Now, let's write a Dockerfile.
602602

603603
**Dockerfile**
604604
```yml
605-
FROM thecodingmachine/php:8.0-v4-apache
605+
FROM thecodingmachine/php:8.1-v4-apache
606606
607607
ARG SSH_PRIVATE_KEY
608608
ARG SSH_KNOWN_HOSTS
@@ -640,7 +640,7 @@ kind: Pod
640640
spec:
641641
containers:
642642
- name: foobar
643-
image: thecodingmachine/php:8.0-v4-apache
643+
image: thecodingmachine/php:8.1-v4-apache
644644
securityContext:
645645
allowPrivilegeEscalation: true # never use "false" here.
646646
```
@@ -662,7 +662,7 @@ Your `docker-compose.yml` file will typically look like this:
662662
version: '3.3'
663663
services:
664664
php:
665-
image: thecodingmachine/php:8.0-v4-apache
665+
image: thecodingmachine/php:8.1-v4-apache
666666
ports:
667667
- "80:80"
668668
environment:
@@ -688,7 +688,7 @@ If for some reason, the container name is not "blackfire", you can customize the
688688
version: '3.3'
689689
services:
690690
php:
691-
image: thecodingmachine/php:8.0-v4-apache
691+
image: thecodingmachine/php:8.1-v4-apache
692692
environment:
693693
PHP_EXTENSION_BLACKFIRE: 1
694694
BLACKFIRE_AGENT: myblackfire
@@ -723,7 +723,7 @@ This command will generate all the files from the "blueprint" templates.
723723
You can then test your changes using the `build-and-test.sh` command:
724724

725725
```bash
726-
PHP_VERSION=8.0 BRANCH=v4 VARIANT=apache ./build-and-test.sh
726+
PHP_VERSION=8.1 BRANCH=v4 VARIANT=apache ./build-and-test.sh
727727
```
728728

729729
### Additional environment in build-and-test.sh

test-image.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ failure() {
1010
trap 'failure ${LINENO} "$BASH_COMMAND"' ERR
1111

1212
# Use either docker's 'build' command or 'buildx '
13-
export BUILDTOOL="buildx build --load --cache-from=type=local,src=/tmp/buildx-cache --cache-to=type=local,dest=/tmp/buildx-cache --platform=${PLATFORM:$(uname -p)}}"
13+
export BUILDTOOL="buildx build --load --platform=${PLATFORM:-$(uname -p)}"
1414

1515
# Let's replace the "." by a "-" with some bash magic
1616
export BRANCH_VARIANT="${VARIANT//./-}"

0 commit comments

Comments
 (0)