docker-library / php

Docker Official Image packaging for PHP
https://php.net
MIT License
3.84k stars 2.01k forks source link

PHP:8.3-fpm "RUN docker-php-ext-enable" command fails #1535

Closed ericsfomgl closed 3 months ago

ericsfomgl commented 3 months ago

Running the command Run docker-php-ext-enable fails on the latest version of php:8.3-fpm

joshtrichards commented 3 months ago

Can you be more specific?

What's the error? What's the Dockerfile?

P.S. Works for me.

Refs: https://github.com/docker-library/docs/blob/master/php/README.md#pecl-extensions

ericsfomgl commented 3 months ago

This is my Docker file, I am using mssql and it has worked until the latest change from 4 hours ago. i cannot find an older sha to test.

FROM php:8.3-fpm

ARG user
ARG uid

# This command updates the package lists for upgrades and new package installations. Then, it installs the following packages:
# - git: A distributed version control system.
# - curl: A command-line tool for getting or sending data using URL syntax.
# - libpng-dev: The PNG library (development). It's used to handle PNG images.
# - libonig-dev: A library for regular expressions (development). It's used in string manipulation operations.
# - gnupg2: GNU privacy guard - a free implementation of OpenPGP. It's used for secure communication and data storage.
# - libxml2-dev: The XML C parser and toolkit of Gnome (development). It's used for parsing and manipulating XML.
# - libzip-dev: A library for reading, creating, and modifying zip archives (development).

RUN apt update && apt install -y \
    git \
    unzip \
    curl \
    libpng-dev \
    libonig-dev \
    gnupg2 \
    libxml2-dev \
    libzip-dev

# This command fetches the Microsoft repository GPG keys and adds them to the APT keyring. This is necessary to ensure that the packages downloaded from the Microsoft repository are trusted.
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

# This command downloads the Microsoft SQL Server Ubuntu repository configuration file and saves it to the APT sources list directory. This allows APT to fetch packages from this repository.
RUN curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

# This command updates the package lists for upgrades and new package installations.
RUN apt-get update

# This command installs the Microsoft ODBC driver for SQL Server (msodbcsql18) and the ODBC Development Headers (unixodbc-dev). The EULA acceptance is required for the installation of msodbcsql18.
RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql18 unixodbc-dev

# These commands install the SQL Server extensions for PHP. These extensions provide a procedural interface and PDO interface to the Microsoft SQL Server.
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv
RUN pecl install redis
RUN pecl install xdebug

RUN echo "[xdebug]" > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "zend_extension=xdebug" > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.mode=coverage,develop,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.discover_client_host=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.log=/tmp/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN touch /tmp/xdebug.log && chmod 777 /tmp/xdebug.log

# This command enables the SQL Server extensions in PHP.
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv redis xdebug

# This command cleans up the APT cache and removes files from the /var/lib/apt/lists directory. This is done to reduce the size of the Docker image.
RUN apt clean && rm -rf /var/lib/apt/lists/*

# This command copies the composer binary from the composer:latest Docker image to the /usr/bin directory of the current Docker image. Composer is a dependency manager for PHP.
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# This command creates a new user with the user ID specified by the $uid variable, and adds the new user to the www-data and root groups. The home directory of the new user is set to /home/$user.
RUN useradd -G www-data,root -u $uid -d /home/$user $user

# This command creates a .composer directory in the home directory of the new user, and changes the ownership of the home directory and its contents to the new user. The .composer directory is used by Composer to store global packages and cache.
RUN mkdir -p /home/$user/.composer && \
    chown -R $user:$user /home/$user

WORKDIR /var/www

USER $user
ericsfomgl commented 3 months ago

Yeah thats fair, i wasn't specific in my initial report, when i run the command docker compose up --build -d.. it just hangs image

ericsfomgl commented 3 months ago

Upon further review, it was my xdebug instance hosing the command. i rewrote part of the script to this, and just removed xdebug for now and i am working again.

# These commands install the SQL Server extensions for PHP. These extensions provide a procedural interface and PDO interface to the Microsoft SQL Server.
RUN pecl install sqlsrv \
    && docker-php-ext-enable sqlsrv
RUN pecl install pdo_sqlsrv \
    && docker-php-ext-enable pdo_sqlsrv
RUN pecl install redis \
    && docker-php-ext-enable redis