Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
FROM php:7.2-cli
FROM php:7.4-cli-buster

# Debian Buster (base of php:7.4-cli-buster) is EOL; package indexes moved to archive.debian.org.
RUN set -xe \
&& sed -i 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.list \
&& sed -i 's|security.debian.org/debian-security|archive.debian.org/debian-security|g' /etc/apt/sources.list \
&& sed -i '/buster-updates/d' /etc/apt/sources.list

RUN set -xe \
&& apt-get update \
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,31 @@ $ composer test

Money requires a set of dependencies, so you might want to run it in Docker.

The image is based on `php:7.4-cli-buster`, which uses Debian Buster. That release is end-of-life, so the Dockerfile points `apt` at [archive.debian.org](https://archive.debian.org/debian/) before installing extensions. Without that step, `docker build` fails during `apt-get update` with errors such as `404 Not Found` on `security.debian.org` or missing Release files for Buster.

Use the same PHP major version in Docker as the one you used for `composer install` on the host. The container mounts your local `vendor/` directory; if Docker runs an older PHP (for example 7.2 while dependencies were resolved on 7.4), PHPUnit can fail with hundreds of `ParseError`s in `vendor/` (often in packages used by Prophecy, such as `phpdocumentor/reflection-docblock`).

First, build the image locally:

```bash
$ docker build -t moneyphp .
```

Optional: run composer install fully inside Docker
The image doesn’t include Composer.
One-off install, (use single quotes around the whole script — not backticks):

```bash
docker run --rm -it -v $PWD:/app -w /app moneyphp bash -c '
apt-get update -qq &&
apt-get install -y -qq git unzip &&
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer &&
git config --global --add safe.directory /app &&
composer config allow-plugins.php-http/discovery true &&
composer install --no-interaction
'
```

Then run the tests:

```bash
Expand Down