5

I'm building a Docker image with Alpine, php7.2-fpm and Composer.

The problem happens while trying to install Composer, which uses https to download the installer via php.

I added the repository to be able to install php7.2 (which is used to install composer) and its packages:

RUN wget -O /etc/apk/keys/phpearth.rsa.pub https://repos.php.earth/alpine/phpearth.rsa.pub && \
    echo "https://repos.php.earth/alpine/v3.7" >> /etc/apk/repositories && \
    apk update

The following error occurs when I try to download composer:

/ # php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
PHP Warning:  copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP   2. copy() Command line code:1
PHP Warning:  copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP   2. copy() Command line code:1
PHP Warning:  copy(https://getcomposer.org/installer): failed to open stream: No such file or directory in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP   2. copy() Command line code:1

Searching about this error, all I found was related do the openssl php extension.

When trying to install the php7.2-openssl extensions, I get the following error message:

/ # apk add php7.2-openssl
ERROR: unable to select packages:
  php7.2-igbinary (no such package):
    required by: world[php7.2-igbinary]
  php7.2-msgpack (no such package):
    required by: world[php7.2-msgpack]
  php7.2-readline (no such package):
    required by: world[php7.2-readline]
  so:libcrypto.so.42 (no such package):
    required by: php7.2-openssl-7.2.16-r0[so:libcrypto.so.42]
  so:libssl.so.44 (no such package):
    required by: php7.2-openssl-7.2.16-r0[so:libssl.so.44]

If I force the installation with "-f", it looks like it installed, but not really. The apk list php* --installed command does not show the openssl extension and the https request still returning the same https error.

Another way to install Composer would not be the best thing for me. Eventually I will need to use https through php anyway.

I'm using the last Alpine Docker base image version to date. Which is "3.14.2".

I wonder if it has something to do with the added repository version (3.7) compared to the image version (3.14.2).

I'd love to understand what is happening.

  • 3
    Is there a reason you are using "repos.php.earth"? I don't know what's in it, but if you're just after PHP maybe you'll have better luck with the official repo? PHP 7.2 builds are no longer listed [on the main tags list](https://github.com/docker-library/docs/blob/master/php/README.md#supported-tags-and-respective-dockerfile-links) (linked from [the main repo](https://hub.docker.com/_/php)). But that doesn't necessarily mean the builds don't exist any more. There's probably a better way to find them but here's what I did: ... – Don't Panic Sep 22 '21 at 07:39
  • 3
    Scrolling down that page there's a link to [the git history of the page itself](https://github.com/docker-library/docs/commits/master/php). I scrolled to the bottom of the page and chose the link from "Nov 12, 2020" to see [what the page looked like then](https://github.com/docker-library/docs/tree/c94e76ddb29c75501fa882a11157d7760762975d/php). Sure enough, there's a few php-fpm 7.2 Alpine builds listed. I tried one of them randomly and it still exists: `docker pull php:7.2-fpm-alpine3.11` (which works). I chose that date and version randomly, hunt around if you're after specific versions. – Don't Panic Sep 22 '21 at 07:39
  • Hey did you find any workaround for phpearth.rsa.pub file? – Leo Oct 12 '21 at 15:05
  • I ended up using a not alpine php-fpm image. But I gave this alpine approach a try. I could not make it work the way a was trying. Although @Don'tPanic's response was very accurate. Using the image he suggested, I was able to use https in php. I'm still not knowing why that was happening, but his/her response made it work. – Kevin Souza Oct 18 '21 at 19:29

1 Answers1

0

recently I had faced the same issue. Fixed it, by downgrading the alpine to earlier stable version.

HV Sharma
  • 4,891
  • 3
  • 15
  • 30