Skip to content

Commit 8e44ae0

Browse files
committed
Compile libmpdec-dev from sources
The package is not available on recent PHP 8.x images which are based on Debian Bookworm. See docker-library/php#1416.
1 parent 68343ec commit 8e44ae0

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,11 @@ Also, if you already have Docker installed, you can run the tests in a docker co
377377
./dockerfile.sh | docker build -t msgpack -
378378
```
379379

380-
The command above will create a container named `msgpack` with PHP 8.1 runtime. You may change the default runtime
380+
The command above will create a container named `msgpack` with PHP 8.2 runtime. You may change the default runtime
381381
by defining the `PHP_IMAGE` environment variable:
382382

383383
```sh
384-
PHP_IMAGE='php:8.0-cli' ./dockerfile.sh | docker build -t msgpack -
384+
PHP_IMAGE='php:8.1-cli' ./dockerfile.sh | docker build -t msgpack -
385385
```
386386

387387
> *See a list of various images [here](https://hub.docker.com/_/php).*

dockerfile.sh

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
11
#!/usr/bin/env bash
22

33
if [[ -z "$PHP_IMAGE" ]]; then
4-
PHP_IMAGE='php:8.1-cli'
4+
PHP_IMAGE='php:8.2-cli'
55
fi
66

77
RUN_CMDS=''
8-
if [[ -z "$EXT_DISABLE_DECIMAL" || "0" == "$EXT_DISABLE_DECIMAL" || "false" == "$EXT_DISABLE_DECIMAL" ]] ; then
9-
RUN_CMDS="$RUN_CMDS && \\\\\n apt-get install -y libmpdec-dev"
10-
RUN_CMDS="$RUN_CMDS && \\\\\n pecl install decimal && docker-php-ext-enable decimal"
11-
fi
12-
138
if [[ -n "$COVERAGE_FILE" ]]; then
149
RUN_CMDS="$RUN_CMDS && \\\\\n pecl install pcov && docker-php-ext-enable pcov"
1510
fi
1611

12+
if [[ -z "$EXT_DISABLE_DECIMAL" || "0" == "$EXT_DISABLE_DECIMAL" || "false" == "$EXT_DISABLE_DECIMAL" ]] ; then
13+
# PHP 8.x images are based on Debian Bookworm, where the libmpdec-dev package
14+
# is not available, therefore the package has to be compiled from sources.
15+
# See https://github.com/docker-library/php/pull/1416.
16+
17+
MPDEC_RELEASE_NAME="mpdecimal-2.5.1"
18+
MPDEC_URL="https://www.bytereef.org/software/mpdecimal/releases/$MPDEC_RELEASE_NAME.tar.gz"
19+
MPDEC_SHA256_SUM="9f9cd4c041f99b5c49ffb7b59d9f12d95b683d88585608aa56a6307667b2b21f"
20+
MPDEC_TMP_DIR="/tmp/$MPDEC_RELEASE_NAME"
21+
MPDEC_TMP_ARCHIVE="$MPDEC_TMP_DIR/$MPDEC_RELEASE_NAME.tar.gz"
22+
23+
RUN_CMDS="$RUN_CMDS\\n\\nRUN"
24+
RUN_CMDS="$RUN_CMDS mkdir -p $MPDEC_TMP_DIR"
25+
RUN_CMDS="$RUN_CMDS && \\\\\n cd $MPDEC_TMP_DIR"
26+
RUN_CMDS="$RUN_CMDS && \\\\\n curl -LO $MPDEC_URL"
27+
RUN_CMDS="$RUN_CMDS && \\\\\n echo \"$MPDEC_SHA256_SUM $MPDEC_TMP_ARCHIVE\" | sha256sum --check --status -"
28+
RUN_CMDS="$RUN_CMDS && \\\\\n tar xf $MPDEC_TMP_ARCHIVE"
29+
RUN_CMDS="$RUN_CMDS && \\\\\n cd $MPDEC_RELEASE_NAME"
30+
RUN_CMDS="$RUN_CMDS && \\\\\n ./configure && make && make install"
31+
RUN_CMDS="$RUN_CMDS && \\\\\n rm -rf $MPDEC_TMP_DIR"
32+
RUN_CMDS="$RUN_CMDS && \\\\\n pecl install decimal && docker-php-ext-enable decimal"
33+
fi
34+
1735
COMPOSER_REMOVE=''
1836

1937
echo -e "

0 commit comments

Comments
 (0)