I'm trying to install PHPUnit using a dockerfile based on the image php:7.4-fpm-alpine. My dockerfile is like this:
FROM php:7.4-fpm-alpine
RUN touch /var/log/error_log
ADD ./php/www.conf /usr/local/etc/php-fpm.d/www.conf
RUN addgroup -g 1000 wp && adduser -G wp -g wp -s /bin/sh -D wp
RUN mkdir -p /var/www/html
RUN chown wp:wp /var/www/html
WORKDIR /var/www/html
RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
RUN chmod x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#install PHPunit
RUN curl -O https://phar.phpunit.de/phpunit-6.5.phar
RUN chmod x phpunit-6.5.phar && mv phpunit-6.5.phar /usr/local/bin/phpunit
RUN phpunit --version
But I keep getting the error:
=> ERROR [7/7] RUN phpunit --version 0.4s
[7/7] RUN phpunit --version: #11 0.348 /usr/local/bin/phpunit: line 1: can't open html: no such file #11 0.348 /usr/local/bin/phpunit: line 2: syntax error: unexpected redirection
I don't know why the phpunit command is not available. Can anyone give me a little help?
CodePudding user response:
maik@LA-027:~/docker$ php phpunit-6.5.phar --version
<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
your source gives back the 302.
the phpunit-6.5.phar does not exist on the site. has to be phpunit-6.5.0.phar
simply have a look on the phar list
you have installed composer, why don't you use compose to intall phpunit?
composer require phpunit/phpunit ^6.5