mlocati / docker-php-extension-installer

Easily install PHP extensions in Docker containers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to use composer in php 8.3

suyar opened this issue · comments

Version of install-php-extensions

latest

Error description

  1. With Dockerfile
FROM php:8.3-fpm

ENV TZ=Asia/Shanghai

RUN set -eux; \
    apt-get update \
    && apt-get install -y unzip \
    && rm -rf /var/lib/apt/lists/*

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN set -eux; \
    chmod +x /usr/local/bin/install-php-extensions; \
    install-php-extensions \
    swoole

COPY --from=composer /usr/bin/composer /usr/bin/composer

EXPOSE 9000
CMD ["php-fpm", "-R"]

Then build and run

sudo docker build -t testphp .
sudo docker run -it --rm testphp composer create-project hyperf/hyperf-skeleton -vvv

Error

Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/var/www/html): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Executing command (/var/www/html): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/var/www/html): git log --pretty="%H" -n1 HEAD
Executing command (/var/www/html): hg branch
Executing command (/var/www/html): fossil branch list
Executing command (/var/www/html): fossil tag list
Executing command (/var/www/html): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /root/.composer/composer.json

Downloading https://repo.packagist.org/packages.json
[200] https://repo.packagist.org/packages.json
Segmentation fault
  1. With Dockerfile
FROM php:8.3-fpm

ENV TZ=Asia/Shanghai

RUN set -eux; \
    apt-get update \
    && apt-get install -y unzip \
    && rm -rf /var/lib/apt/lists/*

COPY --from=composer /usr/bin/composer /usr/bin/composer

EXPOSE 9000
CMD ["php-fpm", "-R"]

Then build and run

sudo docker build -t testphp .
sudo docker run -it --rm testphp composer create-project hyperf/hyperf-skeleton -vvv

It is possible to continue down the line, but there are some warnings

Running 2.6.5 (2023-10-06 10:11:52) with PHP 8.3.0 on Linux / 5.15.133.1-microsoft-standard-WSL2
Failed to initialize global composer: Composer could not find the config file: /root/.composer/composer.json
To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage
Creating a "hyperf/hyperf-skeleton" project at "./hyperf-skeleton"
Checked CA file /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a file.
Checked directory /etc/pki/tls/certs/ca-bundle.crt does not exist or it is not a directory.
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/var/www/html): 'git' 'branch' '-a' '--no-color' '--no-abbrev' '-v'
Executing command (/var/www/html): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/var/www/html): git log --pretty="%H" -n1 HEAD
Executing command (/var/www/html): hg branch
Executing command (/var/www/html): fossil branch list
Executing command (/var/www/html): fossil tag list
Executing command (/var/www/html): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /root/.composer/composer.json

Downloading https://repo.packagist.org/packages.json
[200] https://repo.packagist.org/packages.json
Writing /root/.composer/cache/repo/https---repo.packagist.org/packages.json into cache
Downloading https://repo.packagist.org/p2/hyperf/hyperf-skeleton.json
[200] https://repo.packagist.org/p2/hyperf/hyperf-skeleton.json
Writing /root/.composer/cache/repo/https---repo.packagist.org/provider-hyperf~hyperf-skeleton.json into cache
Installing hyperf/hyperf-skeleton (v3.1.1)
  - Downloading hyperf/hyperf-skeleton (v3.1.1)
Downloading https://api.github.com/repos/hyperf/hyperf-skeleton/zipball/6a550f58daaf8585ac48ca72e82a65bfb39c8669
[302] https://api.github.com/repos/hyperf/hyperf-skeleton/zipball/6a550f58daaf8585ac48ca72e82a65bfb39c8669
Following redirect (1) https://codeload.github.com/hyperf/hyperf-skeleton/legacy.zip/6a550f58daaf8585ac48ca72e82a65bfb39c8669
[200] https://codeload.github.com/hyperf/hyperf-skeleton/legacy.zip/6a550f58daaf8585ac48ca72e82a65bfb39c8669
Writing /root/.composer/cache/files/hyperf/hyperf-skeleton/fb72281b030d2194d5886f1576083d740764b997.zip into cache from /var/www/html/vendor/composer/tmp-2c010b291c0910b58ea4c772224ab45b.zip
  - Installing hyperf/hyperf-skeleton (v3.1.1): Extracting archive
Executing async command (CWD): '/usr/bin/unzip' -qq '/var/www/html/vendor/composer/tmp-2c010b291c0910b58ea4c772224ab45b.zip' -d '/var/www/html/vendor/composer/e7b07d4e'
Executing async command (CWD): rm -rf '/var/www/html/vendor/composer/e7b07d4e'
Downloading https://packagist.org/downloads/
[201] https://packagist.org/downloads/
Created project in /var/www/html/hyperf-skeleton
Reading ./composer.json (/var/www/html/hyperf-skeleton/composer.json)
Loading config file ./composer.json (/var/www/html/hyperf-skeleton/composer.json)
Failed to initialize global composer: Composer could not find the config file: /root/.composer/composer.json

> post-root-package-install: @php -r "file_exists('.env') || copy('.env.example', '.env');"
Executing command (CWD): '/usr/local/bin/php' -d allow_url_fopen='1' -d disable_functions='' -d memory_limit='1536M' -r "file_exists('.env') || copy('.env.example', '.env');"
> pre-update-cmd: Installer\Script::install
Setting up optional packages
Setup data and cache dir
Removing installer development dependencies

  What time zone do you want to setup ?
  [n] Default time zone for php.ini
Make your selection or type a time zone name, like Asia/Shanghai (n):
...

Docker image

php:8.3-fpm

Minimal Dockerfile

FROM php:8.3-fpm

ENV TZ=Asia/Shanghai

RUN set -eux; \
    apt-get update \
    && apt-get install -y unzip \
    && rm -rf /var/lib/apt/lists/*

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN set -eux; \
    chmod +x /usr/local/bin/install-php-extensions; \
    install-php-extensions \
    swoole

COPY --from=composer /usr/bin/composer /usr/bin/composer

EXPOSE 9000
CMD ["php-fpm", "-R"]

How is this error related to install-php-extensions?

How is this error related to install-php-extensions?

I’m not sure if this is caused by the installation of Swoole, but after installing the extension, the composer cannot run correctly. I tried to compare it with the installation of the extension without using a script, although there were some warnings, it could still continue to execute.

Can you try to install composer with my script (see https://github.com/mlocati/docker-php-extension-installer#installing-composer ), without the apt-get calls?

Something like this:

FROM php:8.3-fpm

ENV TZ=Asia/Shanghai

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN set -eux; \
    chmod +x /usr/local/bin/install-php-extensions; \
    install-php-extensions \
    swoole @composer

EXPOSE 9000
CMD ["php-fpm", "-R"]
commented

I still have the same error after using your sample,
this is my error.
image
by the way.
In docker, when swoole is installed and compiled from source code, composer works fine

now I'm trying to install swoole with pecl to see if anything goes wrong....

Can you try to install composer with my script (see https://github.com/mlocati/docker-php-extension-installer#installing-composer ), without the apt-get calls?

Something like this:

FROM php:8.3-fpm

ENV TZ=Asia/Shanghai

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN set -eux; \
    chmod +x /usr/local/bin/install-php-extensions; \
    install-php-extensions \
    swoole @composer

EXPOSE 9000
CMD ["php-fpm", "-R"]
commented

pecl is ok too

commented

After I kept trying, I found the problem. But I can't change it.

Problem cause: When enable-swoole-curl="yes" is enabled during swoole installation, composer suffers from Segmentation fault

Solution: swoole don't turn on enable-swoole-curl

This doesn’t seem to be an issue with docker-php-extension-installer, so I’m going to close it for now. If I find the perfect solution, I’ll come back and add more information.

There are some other reports, however, the problem has not been resolved:
composer/composer#10317
composer/composer#11740
https://bugs.php.net/bug.php?id=81674

commented

this is swoole bug .
swoole/docker-swoole#45