Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pecl install redis on php8 fails #1118

Closed
joepagan opened this issue Jan 16, 2021 · 16 comments
Closed

pecl install redis on php8 fails #1118

joepagan opened this issue Jan 16, 2021 · 16 comments

Comments

@joepagan
Copy link

joepagan commented Jan 16, 2021

2021-01-22 Update:

As highlighted here updating docker for mac to at least 3.1 will resolve this.

Issue appears to be to do with alpine rather than this repo.


Update:

php:8-fpm-alpine fails
php:8-fpm-alpine3.12 works


tl;dr I want to pecl install redis on php:8-fpm-alpine.

When trying to build FROM php:8-fpm-alpine with a standard pecl install redis I get this:

No releases available for package "pecl.php.net/redis"
install failed

It looks like install-php-extensions redis even fails, looks like DNS issue:

### INSTALLING REMOTE MODULE redis ###
  - Installing redis (latest-stable): Downloading (failed)
Downloading (failed)
Downloading (failed)
In RemoteFilesystem.php line 560:

  The "https://pecl.php.net/get/redis" file could not be downloaded: php_netw
  ork_getaddresses: getaddrinfo failed: Name does not resolve
  Failed to open stream: php_network_getaddresses: getaddrinfo failed: Name d
  oes not resolve

It's very possible my issue is ipv6 related, after removing redis from being installed on my docker file and running ping inside the php container:

/var/www/html # ping pecl.php.net
ping: bad address 'pecl.php.net'

forced ipv4 ping:

/var/www/html # ping pecl.php.net -4
PING pecl.php.net (104.236.228.160): 56 data bytes
64 bytes from 104.236.228.160: seq=0 ttl=37 time=108.274 ms
64 bytes from 104.236.228.160: seq=1 ttl=37 time=96.366 ms
^C
--- pecl.php.net ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 96.366/102.320/108.274 ms

forced ipv6 ping:

/var/www/html # ping pecl.php.net -6
ping: bad address 'pecl.php.net'

Is this because there is no ipv6 record on the domain, or, maybe something wrong with my docker-compose.yml or Dockerfile?

version: "3.8"
services:
    php-fpm:
      build:
        context: ./
        dockerfile: ./docker/development/config/php-fpm.dockerfile
      volumes:
        - ./:/var/www/site
      networks:
        - app
    nginx:
      build:
        context: ./
        dockerfile: ./docker/development/config/nginx.dockerfile
      networks:
        - app
volumes:
  mysqldata:
networks:
  app:
    driver: bridge

php-fpm.dockerfile:

ARG PHP_VERSION="8"
ARG PROJECT_TYPE
FROM php:${PHP_VERSION}-fpm-alpine

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN pecl install redis

CMD [ "php-fpm" ]

Change: Cut out most of my RUN value in the dockerfile which is not relevant to the issue

@joeyleake
Copy link

I'm seeing similar issues on php:7.4.14-fpm-alpine3.13.

curl -fSL https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz -o pcre-8.44.tar.gz
is failing with:
curl: (6) Could not resolve host: ftp.pcre.org
but works fine if I revert to php:7.4.14-fpm-alpine3.12.

@Gemorroj
Copy link

same for xdebug on php:7.4-fpm-alpine

@cdaguerre
Copy link
Contributor

cdaguerre commented Jan 17, 2021

Hi, I'm facing the same issue.
Definetly not a solution but a workaround for now, add this to your dockerfile (before any pecl calls):

RUN curl -fsSL -o php.tar.xz.asc "$PHP_ASC_URL"; \
	export GNUPGHOME="$(mktemp -d)"; \
	for key in $GPG_KEYS; do \
		gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys "$key"; \
	done; \
	gpg --batch --verify php.tar.xz.asc php.tar.xz; \
	gpgconf --kill all; \
	rm -rf "$GNUPGHOME"; 

Basically this is a snippet from the official php dockerfile replacing
ha.pool.sks-keyservers.net to ipv4.pool.sks-keyservers.net which forces ipv4 from inside the container and fixes the pecl problem you're facing.

EDIT: Unrelated comment, please disregard.

@joepagan
Copy link
Author

joepagan commented Jan 17, 2021

@cdaguerre even if I take the snippet from the php8 Dockerfile with the accompanying ENV variables and prefix this before pecl install x it still fails.

Unless you meant this would only work if building from source which is not what I wish to do here.

@joepagan
Copy link
Author

joepagan commented Jan 17, 2021

@joeyleake you could possibly resolve your issue with the --ipv4 flag

Thanks for pointing out alpine3.12 works, I have tried php:8-fpm-alpine3.12 and can confirm that it seems like php:8-fpm-alpine (which installs alpine3.13) appears to be the issue for this failing. Updated the original comment

@cdaguerre
Copy link
Contributor

@joepagan you're right, my comment was totally unrelated, sorry for wasting your time.
pecl and pear commands are being deprecated in php8 apparently anyway.
This works on php8 (includes your --ipv4 fix), just tried it:

ARG PHP_VERSION="8.0"
ARG ALPINE_VERSION="3.13"
FROM php:${PHP_VERSION}-alpine${ALPINE_VERSION}

RUN mkdir -p /usr/src/php/ext/redis; \
	curl -fsSL https://pecl.php.net/get/redis --ipv4 | tar xvz -C "/usr/src/php/ext/redis" --strip 1; \
	docker-php-ext-install redis;

@joepagan
Copy link
Author

joepagan commented Jan 17, 2021

Thanks for the suggestion @cdaguerre I can confirm that works! I presume pecl is propbably using curl behind the scenes.

Using that methodology we can actually just completely bypass pecl and go straight for the release on their github... still need ipv4 flag tho:

RUN mkdir -p /usr/src/php/ext/redis; \
    curl -fsSL --ipv4 https://github.com/phpredis/phpredis/archive/5.3.2.tar.gz | tar xvz -C "/usr/src/php/ext/redis" --strip 1; \
    docker-php-ext-install redis

I believe there WAS an intention to remove pear & pecl but they've since back tracked, related threads:

#851
#1088

I suspect this issue is technically one for alpine to resolve further upstream but may as well keep this open for one of the contributors here to comment, surely this alpine (or curl) version is breaking a lot of things if they are forcing ipv6 on all curl commands

Update:

Looks like this change also makes installing packages from composer impossible

@janwebdev
Copy link

I have

configure: error: Please reinstall the libzstd distribution
ERROR: `/tmp/pear/temp/redis/configure --with-php-config=/usr/local/bin/php-config --enable-redis-igbinary=y --enable-redis-lzf=y --enable-redis-zstd=y' failed

when trying to install redis... :/

adding

RUN apk --no-cache add --update \
        libzip-dev \

does not help

@keksa
Copy link

keksa commented Jan 18, 2021

Had the same issue and found this docker/for-mac#5020 - updating Docker for Mac to 3.1.0 fixed the problem for me.

@joepagan
Copy link
Author

I can confirm that has fixed it for me too!

Not sure if the repo contributors deem that a sufficient fix so will leave this for them to close.

@jalendport
Copy link

Had the same issue (but with the imagick package) and updating to Docker 3.1.0 seemed to do the trick for me as well...

@janwebdev
Copy link

I have

configure: error: Please reinstall the libzstd distribution
ERROR: `/tmp/pear/temp/redis/configure --with-php-config=/usr/local/bin/php-config --enable-redis-igbinary=y --enable-redis-lzf=y --enable-redis-zstd=y' failed

when trying to install redis... :/

adding

RUN apk --no-cache add --update \
        libzip-dev \

does not help

adding

 RUN apk --no-cache add --update \
         zstd-dev \

helped, if someone cares :)

@joepagan
Copy link
Author

On reflection, As this issue is likely caused upstream and can be resolved by updating I'll close this.

@Gemorroj
Copy link

but problem still exists for docker-win.

@joepagan
Copy link
Author

@Gemorroj if there is no docker-win update that resolves this create an issue on the alpine repo

@ttodua
Copy link

ttodua commented Jul 20, 2021

pickle is becoming standard from PHP 7.3, so do a favour to yourself and use pickle:
pickle install redis

@docker-library docker-library locked as resolved and limited conversation to collaborators Jul 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants