Skip to content

Commit

Permalink
Compile libmpdec-dev from sources
Browse files Browse the repository at this point in the history
The package is not available on recent PHP 8.x images which are based on
Debian Bookworm.

See docker-library/php#1416.
  • Loading branch information
rybakit committed Jun 18, 2023
1 parent 68343ec commit 8e44ae0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ Also, if you already have Docker installed, you can run the tests in a docker co
./dockerfile.sh | docker build -t msgpack -
```

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

```sh
PHP_IMAGE='php:8.0-cli' ./dockerfile.sh | docker build -t msgpack -
PHP_IMAGE='php:8.1-cli' ./dockerfile.sh | docker build -t msgpack -
```

> *See a list of various images [here](https://hub.docker.com/_/php).*
Expand Down
30 changes: 24 additions & 6 deletions dockerfile.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
#!/usr/bin/env bash

if [[ -z "$PHP_IMAGE" ]]; then
PHP_IMAGE='php:8.1-cli'
PHP_IMAGE='php:8.2-cli'
fi

RUN_CMDS=''
if [[ -z "$EXT_DISABLE_DECIMAL" || "0" == "$EXT_DISABLE_DECIMAL" || "false" == "$EXT_DISABLE_DECIMAL" ]] ; then
RUN_CMDS="$RUN_CMDS && \\\\\n apt-get install -y libmpdec-dev"
RUN_CMDS="$RUN_CMDS && \\\\\n pecl install decimal && docker-php-ext-enable decimal"
fi

if [[ -n "$COVERAGE_FILE" ]]; then
RUN_CMDS="$RUN_CMDS && \\\\\n pecl install pcov && docker-php-ext-enable pcov"
fi

if [[ -z "$EXT_DISABLE_DECIMAL" || "0" == "$EXT_DISABLE_DECIMAL" || "false" == "$EXT_DISABLE_DECIMAL" ]] ; then
# PHP 8.x images are based on Debian Bookworm, where the libmpdec-dev package
# is not available, therefore the package has to be compiled from sources.
# See https://github.com/docker-library/php/pull/1416.

MPDEC_RELEASE_NAME="mpdecimal-2.5.1"
MPDEC_URL="https://www.bytereef.org/software/mpdecimal/releases/$MPDEC_RELEASE_NAME.tar.gz"
MPDEC_SHA256_SUM="9f9cd4c041f99b5c49ffb7b59d9f12d95b683d88585608aa56a6307667b2b21f"
MPDEC_TMP_DIR="/tmp/$MPDEC_RELEASE_NAME"
MPDEC_TMP_ARCHIVE="$MPDEC_TMP_DIR/$MPDEC_RELEASE_NAME.tar.gz"

RUN_CMDS="$RUN_CMDS\\n\\nRUN"
RUN_CMDS="$RUN_CMDS mkdir -p $MPDEC_TMP_DIR"
RUN_CMDS="$RUN_CMDS && \\\\\n cd $MPDEC_TMP_DIR"
RUN_CMDS="$RUN_CMDS && \\\\\n curl -LO $MPDEC_URL"
RUN_CMDS="$RUN_CMDS && \\\\\n echo \"$MPDEC_SHA256_SUM $MPDEC_TMP_ARCHIVE\" | sha256sum --check --status -"
RUN_CMDS="$RUN_CMDS && \\\\\n tar xf $MPDEC_TMP_ARCHIVE"
RUN_CMDS="$RUN_CMDS && \\\\\n cd $MPDEC_RELEASE_NAME"
RUN_CMDS="$RUN_CMDS && \\\\\n ./configure && make && make install"
RUN_CMDS="$RUN_CMDS && \\\\\n rm -rf $MPDEC_TMP_DIR"
RUN_CMDS="$RUN_CMDS && \\\\\n pecl install decimal && docker-php-ext-enable decimal"
fi

COMPOSER_REMOVE=''

echo -e "
Expand Down

0 comments on commit 8e44ae0

Please sign in to comment.