Docker + PHP:8.1.1-FPM how to install imagick php extension? - php

Trying to install imagick for php 8.1.1.
On image of my Dockerfile below composer install gives the following error :
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires PHP extension ext-imagick ^3.6 but it is missing from your system. Install or enable PHP's imagick extension.
To enable extensions, verify that they are enabled in your .ini files:
-
- /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
- /usr/local/etc/php/conf.d/docker-php-ext-calendar.ini
- /usr/local/etc/php/conf.d/docker-php-ext-gd.ini
- /usr/local/etc/php/conf.d/docker-php-ext-intl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
- /usr/local/etc/php/conf.d/docker-php-ext-xsl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
I tried various solutions
apt install php-imagick gives error:
Package php-imagick is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
apt install php8.1-imagick does not find any package
adding RUN docker-php-ext-install php-imagick or RUN docker-php-ext-install imagick at the end of my Dockerfile do not find any package
Dockerfile
FROM php:8.1.1-fpm
RUN apt-get clean && apt-get update \
&& apt-get install -y --no-install-recommends \
locales \
apt-utils \
git \
libicu-dev \
g++ \
libpng-dev \
libxml2-dev \
libzip-dev \
libonig-dev \
libxslt-dev \
unzip \
libpq-dev \
nodejs \
npm \
wget \
apt-transport-https \
lsb-release \
ca-certificates
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
RUN curl -sS https://getcomposer.org/installer | php -- \
&& mv composer.phar /usr/local/bin/composer
RUN curl -sS https://get.symfony.com/cli/installer | bash \
&& mv /root/.symfony/bin/symfony /usr/local/bin
RUN docker-php-ext-configure \
intl \
&& docker-php-ext-install \
pdo pdo_mysql pdo_pgsql opcache intl zip calendar dom mbstring gd xsl
RUN pecl install apcu && docker-php-ext-enable apcu
RUN npm install --global yarn
WORKDIR /var/www/app/
RUN apt-get install -y libmagickwand-dev
RUN apt-get install -y imagemagick
RUN pecl install imagick
COPY ./app/composer.json ./
COPY ./app/composer.lock ./

RUN apt-get update; \
# Imagick extension
apt-get install -y libmagickwand-dev; \
pecl install imagick; \
docker-php-ext-enable imagick; \
# Success
true

Related

Can't install pdo_mysql with docker-php-ext-install

I need help, I can’t install pdo_mysql, ampq or opcache with docker-php-ext-install. I prepared a docker project on a local PC (Mac OSX). On the local PC after build docker image is the final PHP configuration right. When I deploy the project config to the remote Debian server after building it, I have a completely different PHP version (phpinfo). Missing extensions opcache, pdo_mysql, ampq.
I tried to configure it differently and deleted the docker cache on the server, but it didn’t help.
docker system prune -a
My PHP dockerfile:
FROM php:7.4-fpm
WORKDIR /var/www/symfony
RUN apt-get update \
&& docker-php-ext-install mysqli pdo pdo_mysql \
&& docker-php-ext-enable pdo_mysql
RUN apt update && apt-get udpate \
&& apt install -y zlib1g-dev g++ git libicu-dev zip libzip-dev zip libxslt1-dev\
&& docker-php-ext-install intl \
&& pecl install apcu \
&& docker-php-ext-enable apcu \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip \
&& docker-php-ext-install xsl
RUN apt-get update \
&& docker-php-ext-install opcache
RUN apt-get update \
&& apt-get install -y \
librabbitmq-dev \
libssh-dev \
&& pecl install amqp \
&& docker-php-ext-enable amqp
RUN apt-get update && \
apt-get install -y libxml2-dev \
&& docker-php-ext-install soap
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Node.js
RUN curl -sL https://deb.nodesource.com/setup_14.x -o node_setup.sh && \
bash node_setup.sh && \
apt-get install -y nodejs && \
npm install npm -g
# Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn
RUN apt-get update && apt-get install -y cron
ADD ./crontab /etc/cron.d/crontab
#
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/crontab
RUN crontab /etc/cron.d/crontab
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
RUN apt-get update && apt-get install -y supervisor
ADD ./supervisord.conf /etc/supervisor/
# Copy docker entrypoint file
COPY ./entrypoint.sh /entrypoint.sh
# Docker init
RUN ["chmod", "+x", "/entrypoint.sh"]
Not sure if it's a solution to your issue, but let's see.
From https://hub.docker.com/_/php:
If you are having difficulty figuring out which Debian or Alpine packages need to be installed before docker-php-ext-install, then have a look at the install-php-extensions project. This script builds upon the docker-php-ext-* scripts and simplifies the installation of PHP extensions by automatically adding and removing Debian (apt) and Alpine (apk) packages. For example, to install the GD extension you simply have to run install-php-extensions gd. This tool is contributed by community members and is not included in the images, please refer to their Git repository for installation, usage, and issues.
I had similar issues in the past and resolved it by using install-php-extensions. See this comment.

Facade does not implement getFacadeAccessor when running composer update in Laravel [duplicate]

Trying to install imagick for php 8.1.1.
On image of my Dockerfile below composer install gives the following error :
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires PHP extension ext-imagick ^3.6 but it is missing from your system. Install or enable PHP's imagick extension.
To enable extensions, verify that they are enabled in your .ini files:
-
- /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
- /usr/local/etc/php/conf.d/docker-php-ext-calendar.ini
- /usr/local/etc/php/conf.d/docker-php-ext-gd.ini
- /usr/local/etc/php/conf.d/docker-php-ext-intl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
- /usr/local/etc/php/conf.d/docker-php-ext-xsl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
I tried various solutions
apt install php-imagick gives error:
Package php-imagick is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
apt install php8.1-imagick does not find any package
adding RUN docker-php-ext-install php-imagick or RUN docker-php-ext-install imagick at the end of my Dockerfile do not find any package
Dockerfile
FROM php:8.1.1-fpm
RUN apt-get clean && apt-get update \
&& apt-get install -y --no-install-recommends \
locales \
apt-utils \
git \
libicu-dev \
g++ \
libpng-dev \
libxml2-dev \
libzip-dev \
libonig-dev \
libxslt-dev \
unzip \
libpq-dev \
nodejs \
npm \
wget \
apt-transport-https \
lsb-release \
ca-certificates
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
RUN curl -sS https://getcomposer.org/installer | php -- \
&& mv composer.phar /usr/local/bin/composer
RUN curl -sS https://get.symfony.com/cli/installer | bash \
&& mv /root/.symfony/bin/symfony /usr/local/bin
RUN docker-php-ext-configure \
intl \
&& docker-php-ext-install \
pdo pdo_mysql pdo_pgsql opcache intl zip calendar dom mbstring gd xsl
RUN pecl install apcu && docker-php-ext-enable apcu
RUN npm install --global yarn
WORKDIR /var/www/app/
RUN apt-get install -y libmagickwand-dev
RUN apt-get install -y imagemagick
RUN pecl install imagick
COPY ./app/composer.json ./
COPY ./app/composer.lock ./
RUN apt-get update; \
# Imagick extension
apt-get install -y libmagickwand-dev; \
pecl install imagick; \
docker-php-ext-enable imagick; \
# Success
true

Docker / Symfony / MongoDB - Cannot install mongodb with PHP 5.6 FPM

I'm not able to install mongodb extension using php:5.6-fpm image.
What's wrong with my Dockerfile configuration ?
FROM php:5.6-fpm
RUN apt-get update \
&& mkdir -p /usr/share/man/man1 \
&& mkdir -p /usr/share/man/man7 \
&& apt-get install -y --no-install-recommends vim curl debconf subversion git apt-transport-https apt-utils \
build-essential locales acl mailutils wget zip unzip htop vim \
gnupg gnupg1 gnupg2 \
libmemcached-dev zlib1g-dev \
libcurl4-openssl-dev pkg-config libssl-dev libicu-dev g++
RUN docker-php-ext-configure intl
RUN docker-php-ext-install pdo pdo_mysql zip intl
RUN pecl install mongodb
RUN docker-php-ext-enable mongodb
COPY php.ini /usr/local/etc/php/conf.d/php.ini
...
...
I have the following error when executing docker-compose build
Step 5/18 : RUN pecl install mongodb
---> Running in 5cd13b1b969c
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
pecl/mongodb requires PHP (version >= 7.0.0, version <= 7.99.99), installed version is 5.6.40
No valid packages found
install failed
Solution:
RUN pecl install mongodb-1.7.4

Error updating Dockerfile FROM php:7.2-fpm to php:7.3-fpm

Because I want PHP 7.3 features I am trying to update the project from PHP 7.2 to PHP 7.3. Within docker-compose.yml I have:
php:
build: ./docker/php
volumes:
- .:/var/www/html
links:
- mysql:mysql
depends_on:
- mysql
networks:
- pimcorenet
My Dockerfile is like:
FROM php:7.2-fpm
# install git
RUN apt-get update && \
apt-get install -y --no-install-recommends git
#install some base extensions
RUN apt-get install -y \
zlib1g-dev \
zip \
libpng-dev \
exiftool \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libicu-dev \
libpq-dev \
libxpm-dev \
libvpx-dev \
mariadb-client \
libxml2-dev
RUN docker-php-ext-install -j$(nproc) \
zip \
exif \
bcmath \
intl \
pcntl \
mysqli \
pdo \
gd \
pdo_mysql \
pdo_pgsql \
mbstring \
soap \
opcache \
iconv
# Install Imagick
RUN apt-get update && apt-get install -y \
libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick
# Install Composer
RUN echo "Install Composer"
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer --version
I am getting the following error:
E: Failed to fetch
http://cdn-fastly.deb.debian.org/debian/pool/main/r/readline/readline-common_7.0-5_all.deb
Could not resolve 'cdn-fastly.deb.debian.org' E: Failed to fetch
http://cdn-fastly.deb.debian.org/debian/pool/main/j/jquery/libjs-jquery_3.3.1~dfsg-3_all.deb
Could not resolve 'cdn-fastly.deb.debian.org' E: Failed to fetch
http://cdn-fastly.deb.debian.org/debian/pool/main/f/freetype/freetype2-doc_2.9.1-3_all.deb
Could not resolve 'cdn-fastly.deb.debian.org' E: Failed to fetch
http://cdn-fastly.deb.debian.org/debian/pool/main/i/icu/icu-devtools_63.1-6_amd64.deb
Could not resolve 'cdn-fastly.deb.debian.org' E: Failed to fetch
http://cdn-fastly.deb.debian.org/debian/pool/main/j/javascript-common/javascript-common_11_all.deb
Could not resolve 'cdn-fastly.deb.debian.org' ..... more errors
ERROR: Service 'php' failed to build: The command '/bin/sh -c apt-get
install -y zlib1g-dev zip libpng-dev
exiftool libfreetype6-dev libjpeg62-turbo-dev
libmcrypt-dev libicu-dev libpq-dev libxpm-dev
libvpx-dev mariadb-client libxml2-dev' returned a
non-zero code: 100
What is the exact problem with this? Is it because some required PHP extensions are not yet available for PHP 7.3 or have been replaced? How do I resolve this? Just changed FROM php:7.2-fpm to FROM php:7.3-fpm.
You are failing to grok containers. And because of that you are taking the wrong approach.
You shouldn't be trying to 'upgrade' a php 7.2 to container to 7.3.
You should be creating a new container image that is based off 7.3 to begin with.
Incidentally, I would recommend making it me a new, separate service to your existing 7.2 container, i.e. a new Dockerfile, rather than just changing the existing container/Dockerfile. That will allow you to test the two versions alongside each other, rather than having a 'leap of faith' change over.
Also, I'd recommend building off the Debian or Ubuntu images directly, rather than going through the 'official' Docker images. They are only official in the sense of being made by Docker, but they are not quite as well supported in my opinion.
This is the dockerfile I'm using currently: https://github.com/Danack/example/blob/master/docker/php_fpm/Dockerfile Switching 7.2 to 7.3 should 'just work'.

Install debian stretch with php5.6

We are using laravel based on php version 5.6, few days ago Debian removed jessie version (8) so we need to upgrade that to 9, but the issue is its hard to use Debian 9 without php5.6 as scripts like
docker-php-ext-install
does not seem to work there. i attach my section of the installation in the docker-file. Would appreciate if there is a solution to this
I have tried to install the pdo_mysql without the docker-php-ext-install
but it fails cannot locate that..
FROM debian:9.0
RUN apt-get update \
&& apt-get -y install \
apt-transport-https apt-utils \
lsb-release \
ca-certificates \
wget \
mcrypt \
libmcrypt-dev \
git-core \
unzip \
&& wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
&& apt-get update \
&& apt-get -y install gnupg2 php5.6-cli php5.6-fpm \
&& apt-get update \
&& docker-php-ext-install \
mbstring \
pdo_mysql \
mcrypt bcmath\
&& update-alternatives --install /usr/bin/php php /usr/bin/php5.6 90 \
&& update-alternatives --set php /usr/bin/php5.6
And this is the end of the build call :
Reading package lists...
/bin/sh: 1: docker-php-ext-install: not found
docker-php-ext-install is a command provided by official php images. You will find it only on those images or images based on those.
Official docker php images providing php 5.6 still exist on the docker hub:
wget -qO- https://registry.hub.docker.com/v1/repositories/php/tags | jq '.[].name' | grep -P '^"5\.6(?!\.)'
"5.6"
"5.6-alpine"
"5.6-alpine3.4"
"5.6-alpine3.7"
"5.6-alpine3.8"
"5.6-apache"
"5.6-apache-jessie"
"5.6-apache-stretch"
"5.6-cli"
"5.6-cli-alpine"
"5.6-cli-alpine3.4"
"5.6-cli-alpine3.7"
"5.6-cli-alpine3.8"
"5.6-cli-jessie"
"5.6-cli-stretch"
"5.6-fpm"
"5.6-fpm-alpine"
"5.6-fpm-alpine3.4"
"5.6-fpm-alpine3.7"
"5.6-fpm-alpine3.8"
"5.6-fpm-jessie"
"5.6-fpm-stretch"
"5.6-jessie"
"5.6-stretch"
"5.6-zts"
"5.6-zts-alpine"
"5.6-zts-alpine3.4"
"5.6-zts-alpine3.7"
"5.6-zts-alpine3.8"
"5.6-zts-jessie"
"5.6-zts-stretch"
Furthermore, those images are built on top of debian 9:
docker run --rm php:5.6 cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
and provide the docker-php-ext-install command:
docker run --rm php:5.6 which docker-php-ext-install
/usr/local/bin/docker-php-ext-install
I suggest you use one of those official image as the base for your Dockerfile.
FROM php:5.6-fpm
RUN apt-get update \
&& apt-get -y install \
libmcrypt-dev \
mcrypt \
&& docker-php-ext-install \
bcmath \
mbstring \
mcrypt \
pdo_mysql

Categories