mirror of
https://github.com/php/pie.git
synced 2026-03-23 23:12:17 +01:00
Improve Docker instructions in docs/usage.md
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.
This commit is contained in:
@@ -33,10 +33,11 @@ curl -fL --output /tmp/pie.phar https://github.com/php/pie/releases/latest/downl
|
||||
|
||||
### Docker installation
|
||||
|
||||
PIE is published as binary-only Docker image, so you can install it easily during your Docker build:
|
||||
PIE is published as binary-only Docker image, so you can use it easily during your Docker build:
|
||||
|
||||
```Dockerfile
|
||||
COPY --from=ghcr.io/php/pie:bin /pie /usr/bin/pie
|
||||
RUN --mount=type=bind,from=ghcr.io/php/pie:bin,source=/pie,target=/usr/local/bin/pie \
|
||||
pie -V
|
||||
```
|
||||
|
||||
Instead of `bin` tag (which represents latest binary-only image) you can also use explicit version (in `x.y.z-bin` format). Use [GitHub registry](https://ghcr.io/php/pie) to find available tags.
|
||||
@@ -54,17 +55,20 @@ installed.
|
||||
```Dockerfile
|
||||
FROM php:8.4-cli
|
||||
|
||||
# Add the `unzip` package which PIE uses to extract .zip files
|
||||
RUN export DEBIAN_FRONTEND="noninteractive"; \
|
||||
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; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
# Add the `unzip` package which PIE uses to extract .zip files.
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends unzip; \
|
||||
# Use PIE to install an extension...
|
||||
pie install asgrim/example-pie-extension; \
|
||||
# Clean up `unzip`.
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false unzip; \
|
||||
rm -rf /var/lib/apt/lists/*;
|
||||
|
||||
# Copy the pie.phar from the latest `:bin` release
|
||||
COPY --from=ghcr.io/php/pie:bin /pie /usr/bin/pie
|
||||
|
||||
# Use PIE to install an extension...
|
||||
RUN pie install asgrim/example-pie-extension
|
||||
CMD ["php", "-r", "example_pie_extension_test();"]
|
||||
```
|
||||
|
||||
If the extension you would like to install needs additional libraries or other
|
||||
|
||||
Reference in New Issue
Block a user