'getting imagick with extension webp to work with docker
I'm fairly new to docker and am trying to have my webp extension installed and am running into issues. here is my docker file. If you need any other files or more context please let me know.
FROM php:8.0.2-apache
Update packages
RUN apt-get update
# Install PHP and composer dependencies
RUN apt-get install -qq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev libzip-dev sudo vim
# Install Redis
RUN apt-get install -qq redis-server
COPY ./docker-compose/redis/redis.conf /etc/redis/redis.conf
RUN redis-server /etc/redis/redis.conf
# Install Supervisor to keep queue workers going
RUN apt-get install -qq supervisor
RUN mkdir /var/log/support3
COPY ./docker-compose/supervisor/laravel-worker.conf /etc/supervisor/conf.d/laravel-worker.conf
RUN chown -R www-data:www-data /var/log/support3
# Clear out the local repository of retrieved package files
RUN apt-get clean
RUN apt-get update && apt-get install -y libmagickwand-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
# install imagick
# Version is not officially released https://pecl.php.net/get/imagick but following works for PHP 8
RUN mkdir -p /usr/src/php/ext/imagick; \
curl -fsSL https://github.com/Imagick/imagick/archive/06116aa24b76edaf6b1693198f79e6c295eda8a9.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1; \
docker-php-ext-install imagick;
# Install needed extensions
# Here you can install any other extension that you need during the test and deployment process
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install pdo_mysql zip gd
# Install Node
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install nodejs -y
RUN apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb -y
# Install Chrome and dependencies
RUN apt-get install libappindicator1 fonts-liberation wget apt-utils xdg-utils -y
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && dpkg -i google-chrome*.deb
# Install Composer
RUN curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Setup Apache
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers
# RUN ln -s /etc/apache2/sites-available/support3.conf /etc/apache2/sites-enabled/000-default.conf
# COPY . /var/www/html/support3
#COPY .example-index.php /var/www/html/support3/public/index.php
# We need a user with the same UID/GID with host user
# so when we execute CLI commands, all the host file's ownership remains intact
# otherwise command from inside container will create root-owned files and directories
# ARG uid
# RUN useradd -G www-data,root -u $uid -d /home/devuser devuser
# RUN mkdir -p /home/devuser/.composer && \
# chown -R devuser:devuser /home/devuser
RUN mkdir /var/www/html/dts3
RUN chown -R www-data:www-data /var/www/html/dts3
RUN chmod -R 755 /var/www/html/dts3
RUN mkdir /var/www/html/customerSSL
RUN chown -R www-data:www-data /var/www/html/customerSSL
RUN chmod -R 750 /var/www/html/customerSSL
COPY ./docker-compose/apache2/000-support3.conf /etc/apache2/sites-available/000-support3.conf
RUN rm /etc/apache2/sites-enabled/*
RUN a2ensite 000-support3
RUN chown -R www-data:www-data /etc/apache2/sites-enabled
RUN chmod -R 750 /etc/apache2/sites-enabled
RUN echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini
Whenever i go inside my container and look at
php -r "var_dump(gd_info());"
its shows
["GD Version"]=>
string(26) "bundled (2.1.0 compatible)"
["FreeType Support"]=>
bool(true)
["FreeType Linkage"]=>
string(13) "with freetype"
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(false)
["XBM Support"]=>
bool(true)
["WebP Support"]=>
bool(false)
["BMP Support"]=>
bool(true)
["TGA Read Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
I just need webp support inside the docker container. Any help would be appreciated.
Solution 1:[1]
With this installation in Dockerfile, i have webp support with imagick library
FROM php:7.4-apache
RUN apt-get update && apt-get install -y \
nano \
git \
curl \
cron \
supervisor \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip \
libzip-dev \
libxml2-dev \
libmcrypt-dev openssl \
libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mohammad Daneshamooz |
