Skip to content

Improve Docker instructions in docs/usage.md#546

Merged
asgrim merged 1 commit intophp:1.4.xfrom
TimWolla:improve-docker-instructions
Mar 17, 2026
Merged

Improve Docker instructions in docs/usage.md#546
asgrim merged 1 commit intophp:1.4.xfrom
TimWolla:improve-docker-instructions

Conversation

@TimWolla
Copy link
Member

@TimWolla TimWolla commented Mar 17, 2026

This aims to strike a balance between “best practice” and “being easy to understand”. It uses RUN --mount to avoid including PIE in the resulting image and takes care to uninstall unzip as well, but does not provide “extension mechanisms” to install per-extension build or runtime libraries.


The “long example” is now self-contained including a demo CMD:

$ docker build -t test .
[+] Building 0.2s (8/8) FINISHED                                                                                                                                                                                                                                                                                                                                              docker:rootless
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                                                                     0.0s
 => => transferring dockerfile: 641B                                                                                                                                                                                                                                                                                                                                                     0.0s
 => [internal] load metadata for ghcr.io/php/pie:bin                                                                                                                                                                                                                                                                                                                                     0.2s
 => [internal] load metadata for docker.io/library/php:8.4-cli                                                                                                                                                                                                                                                                                                                           0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                                                                                                          0.0s
 => FROM ghcr.io/php/pie:bin@sha256:24df295bb3dbf6cbcb42f49a14eaef043b99ccaa17f8412f3c04eb330e6da12d                                                                                                                                                                                                                                                                                     0.0s
 => [stage-0 1/2] FROM docker.io/library/php:8.4-cli                                                                                                                                                                                                                                                                                                                                     0.0s
 => CACHED [stage-0 2/2] RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin/pie     export DEBIAN_FRONTEND="noninteractive";     set -eux;     apt-get update;     apt-get install -y --no-install-recommends unzip;     pie install asgrim/example-pie-extension;     apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false unzip  0.0s
 => exporting to image                                                                                                                                                                                                                                                                                                                                                                   0.0s
 => => exporting layers                                                                                                                                                                                                                                                                                                                                                                  0.0s
 => => writing image sha256:d8b2494ffd6f830fcb6fde1ca9cd511fac7c6d52f5b9dae92f6fe26fd8e37306                                                                                                                                                                                                                                                                                             0.0s
 => => naming to docker.io/library/test                                                                                                                                                                                                                                                                                                                                                  0.0s
$ docker run -it --rm test
Hello, world!

It comes with just 1.4 MB of additional storage requirements (not the full 11 MB of PIE):

$ docker history test 
IMAGE          CREATED         CREATED BY                                      SIZE      COMMENT
d8b2494ffd6f   6 minutes ago   CMD ["php" "-r" "example_pie_extension_test(…   0B        buildkit.dockerfile.v0
<missing>      6 minutes ago   RUN /bin/sh -c export DEBIAN_FRONTEND="nonin…   1.41MB    buildkit.dockerfile.v0

PR submitter checklist

  • I have read CONTRIBUTING.md
  • I discussed this <bug|feature> with the maintainers in #<issue_number> (complete as appropriate)
  • I have added appropriate tests
  • I confirm that I have the right to submit this under the project's open source licence

This aims to strike a balance between “best practice” and “being easy to
understand”. It uses `RUN --mount` to avoid including PIE in the resulting
image and takes care to uninstall `unzip` as well, but does not provide
“extension mechanisms” to install per-extension build or runtime libraries.
@asgrim asgrim self-assigned this Mar 17, 2026
@asgrim asgrim added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 17, 2026
@asgrim asgrim added this to the 1.4.0 milestone Mar 17, 2026
@asgrim asgrim self-requested a review March 17, 2026 08:59
@asgrim asgrim merged commit c37df9e into php:1.4.x Mar 17, 2026
27 checks passed
@TimWolla TimWolla deleted the improve-docker-instructions branch March 17, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants