Reputation: 615
i have the following simple dockerfile to add php from alpine,
FROM php:7.2-fpm-alpine
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install extensions
RUN docker-php-ext-install mbstring tokenizer mysqli pdo_mysql
COPY ./app /app
WORKDIR /app
RUN composer install
and while running composer install
it complains with this message - The requested PHP extension ext-http * is missing from your system. Install or enable PHP's http extension.
i tried to see if i can install it using 'docker-php-ext-install' but according to here the extension is not included.
also tried to add RUN apk add php-http
, i also got the following error message
PS: it works locally on my local linux machine after installing the extension using sudo apt install php-http
Upvotes: 1
Views: 3595
Reputation: 546
First, you could add a apk update
before adding packages. However the php_http
package does not exist in alpine so you need to compile the pecl module.
Using the following question as an inspiration, I found adding this to your Dockerfile
works well:
RUN apk add --update --virtual .build-deps autoconf g++ make zlib-dev curl-dev libidn2-dev libevent-dev icu-dev libidn-dev
RUN docker-php-ext-install mbstring tokenizer mysqli pdo_mysql json hash iconv
RUN pecl install raphf propro
RUN docker-php-ext-enable raphf propro
RUN pecl install pecl_http
RUN echo -e "extension=raphf.so\nextension=propro.so\nextension=iconv.so\nextension=http.so" > /usr/local/etc/php/conf.d/docker-php-ext-http.ini
RUN rm -rf /usr/local/etc/php/conf.d/docker-php-ext-raphf.ini
RUN rm -rf /usr/local/etc/php/conf.d/docker-php-ext-propro.ini
RUN rm -rf /tmp/*
Upvotes: 2