Before that, I’m new to Docker. I need help with this problem. I got the error when I ran this docker compose run --build --rm server ./vendor/bin/phpunit tests/HelloWorldTest.php, The expected output when I run that compose should be like this:
Hello, Docker!PHPUnit 9.6.13 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 00:00.003, Memory: 4.00 MB
OK (1 test, 1 assertion)
But l got this error: /usr/local/bin/docker-php-entrypoint: 9: exec: ./vendor/bin/phpunit: not found. Please help me how to solve this. I’ve tried to find the solution but can’t find it.
Here is my composer.json code: { "require-dev": { "phpunit/phpunit": "^9.6" } } .
Can you tell me more details @bluepuma77, please? I’ve try figure it out since morning and I’m still struggling.
Here is my Dockerfile setup:
syntax=docker/dockerfile:1
FROM composer:lts as prod-deps
WORKDIR /app
RUN --mount=type=bind,source=./composer.json,target=composer.json
–mount=type=bind,source=./composer.lock,target=composer.lock
–mount=type=cache,target=/tmp/cache
composer install --no-dev --no-interaction
FROM composer:lts as dev-deps
WORKDIR /app
RUN --mount=type=bind,source=./composer.json,target=composer.json
–mount=type=bind,source=./composer.lock,target=composer.lock
–mount=type=cache,target=/tmp/cache
composer install --no-interaction
FROM php:8.2-apache as base
RUN docker-php-ext-install pdo pdo_mysql
COPY ./src /var/www/html
FROM base as development
COPY ./tests /var/www/html/tests
RUN mv “$PHP_INI_DIR/php.ini-development” “$PHP_INI_DIR/php.ini”
COPY --from=dev-deps app/vendor/ /var/www/html/vendor
FROM base as final
RUN mv “$PHP_INI_DIR/php.ini-production” “$PHP_INI_DIR/php.ini”
COPY --from=prod-deps app/vendor/ /var/www/html/vendor
USER www-data
@nurularifin
Hope you have solved it! I encounter the exact same error, turns out I didn’t save the change after adding target:development in the compose.yaml.