Docker Compose & Symfony on Ubuntu - php

When running docker-compose up I am getting the following error:
Service 'web-app' failed to build: The command '/bin/sh -c set -xe && buildDeps=" $PHP_EXTRA_BUILD_DEPS libcurl4-openssl-dev libedit-dev libsqlite3-dev libssl-dev libxml2-dev xz-utils " && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* && curl -fSL "http://php.net/get/$PHP_FILENAME/from/this/mirror" -o "$PHP_FILENAME" && echo "$PHP_SHA256 *$PHP_FILENAME" | sha256sum -c - && curl -fSL "http://php.net/get/$PHP_FILENAME.asc/from/this/mirror" -o "$PHP_FILENAME.asc" && export GNUPGHOME="$(mktemp -d)" && for key in $GPG_KEYS; do gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; done && gpg --batch --verify "$PHP_FILENAME.asc" "$PHP_FILENAME" && rm -r "$GNUPGHOME" "$PHP_FILENAME.asc" && mkdir -p /usr/src/php && tar -xf "$PHP_FILENAME" -C /usr/src/php --strip-components=1 && rm "$PHP_FILENAME" && cd /usr/src/php && ./configure --with-config-file-path="$PHP_INI_DIR" --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" $PHP_EXTRA_CONFIGURE_ARGS --disable-cgi --enable-mysqlnd --enable-mbstring --with-curl --with-libedit --with-openssl --with-zlib && make -j"$(nproc)" && make install && { find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; } && make clean && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false -o APT::AutoRemove::SuggestsImportant=false $buildDeps' returned a non-zero code: 2
Any idea why and how to fix it please?

Related

oci8-2.2.0 does not connect to the database but doesn't return an error either

I'm trying to install oci8-2.2.0 on an ubuntu 18 docker with php 7.2
I'm using the following commands (php-pear and libc6 installed before those):
RUN apt-get update && \
apt-get install -y unzip libaio1 libsnl-dev && \
cd /tmp && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip && \
mkdir -p /opt/oracle && \
cp instantclient-* /opt/oracle/ && \
cd /opt/oracle/ && \
unzip instantclient-basic-linux.x64-21.4.0.0.0dbru.zip && \
unzip instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip && \
unzip instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
rm -rf /var/lib/apt/lists/* instantclient-basic-linux.x64-21.4.0.0.0dbru.zip instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
ln -s /opt/oracle/instantclient_21_4/libclntsh.so.21.1 /usr/lib/libclntsh.so && \
ln -s /lib64/ld-linux-x86-64.so.2 /usr/lib/ld-linux-x86-64.so.2 && \
ln -s /opt/oracle/instantclient_21_4/libnnz21.so /usr/lib/libnnz21.so && \
ln -s /opt/oracle/instantclient_21_4/libclntshcore.so /usr/lib/libclntshcore.so.21.1 && \
echo /opt/oracle/instantclient_21_4 > /etc/ld.so.conf.d/oracle-instantclient.conf
RUN echo "instantclient,/opt/oracle/instantclient_21_4" | pecl install oci8-2.2.0 && \
echo "extension=oci8.so" >> /etc/php/7.2/cli/php.ini && \
echo "extension=oci8.so" >> /etc/php/7.2/apache2/php.ini
PHP Seems to recognize the module and load it, but when I call #oci_new_connect I don't get a connection, but I don't get an error either.
Using sqlplus from the same server connects just fine, so its not that. Another installation with the adminer 4.8.1 docker (alpine & php 7.4) works fine.
I'm completely stumped. Does anyone have an idea where to look next?
Found the issue, needed to add
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/oracle/instantclient_21_4

How to install php Imagick library with docker?

I'm just working on a laravel project which runs on docker using sail.For a feature i need to create functionality which can create thumbnails for pdf's.I figured out it is possible to done using php Imagick class/library.But unfortunately I'm struggling to install it on the project.Anyone knows how to install it using docker?Really appreciate.
This is the Dockerfile.
LABEL maintainer="Taylor Otwell"
ARG WWWGROUP
ARG NODE_VERSION=16
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
&& mkdir -p ~/.gnupg \
&& chmod 600 ~/.gnupg \
&& echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
&& apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C \
&& apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C \
&& echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& apt-get update \
&& apt-get install -y php8.0-cli php8.0-dev \
php8.0-pgsql php8.0-sqlite3 php8.0-gd \
php8.0-curl php8.0-memcached \
php8.0-imap php8.0-mysql php8.0-mbstring \
php8.0-xml php8.0-zip php8.0-bcmath php8.0-soap \
php8.0-intl php8.0-readline php8.0-pcov \
php8.0-msgpack php8.0-igbinary php8.0-ldap \
php8.0-redis php8.0-swoole php8.0-xdebug \
&& php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y yarn \
&& apt-get install -y mysql-client \
&& apt-get install -y postgresql-client \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN update-alternatives --set php /usr/bin/php8.0
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.0
RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.0/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container
EXPOSE 8000
ENTRYPOINT ["start-container"]
The easiest way is to use mlocati/docker-php-extension-installer like this:
FROM php:8.0
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions imagick

Trying to install the GMP extension on Docker / php:5.3

I'm trying to test some PHP code on PHP 5.3 with the GMP extension installed. Here's my Dockerfile:
FROM php:5.3
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906 \
&& apt-get update \
&& apt-get -y install libgmp-dev \
&& docker-php-ext-install gmp
When I try to build that I get an error about how docker-php-ext-install doesn't exist.
Here's my second attempt:
FROM php:5.3
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906 \
&& apt-get update \
&& apt-get -y install php5-gmp
That builds without issue but apparently that doesn't actually result in PHP having the GMP extension. I thought maybe I'd need to add extension=gmp.so to the php.ini file but it's not immediately clear to me where that file lives. php -i | grep ini returns, among other things, this:
Configuration File (php.ini) Path => /usr/local/lib
But there's no php.ini file in that directory. I tried to create one but still no luck.
Per chance there's a PHP 5.3 image floating around that already has the GMP extension installed?
I was able to do it thusly:
FROM php:5.3
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906 \
&& apt-get update \
&& apt-get install -y libgmp-dev wget \
&& ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \
&& cd /tmp \
&& wget --no-check-certificate https://museum.php.net/php5/php-5.3.29.tar.xz \
&& tar xvf php-5.3.29.tar.xz \
&& cd php-5.3.29/ext/gmp \
&& phpize \
&& ./configure \
&& make \
&& make install \
&& echo extension=gmp.so > /usr/local/lib/php.ini
Installing PHP extensions works about like this:
FROM php:5.3
RUN apt-key adv --keyserver keyserver.ubuntu.com \
--recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906 \
&& apt-get update && apt-get -y install php5-gmp libgmp \
&& echo "extension=gmp.so" > /etc/php5/apache2/conf.d/gmp.ini \
&& /etc/init.d/apache2 reload
But the PHP manual reads:
In order to have these functions available, PHP must be compiled with GMP support by using the --with-gmp option.
So the PHP in the Dockerfile needs to be compiled with the --with-gmp option and libgmp-dev.
I use php:8.0-fpm on docker and this worked for me. I hope this work for you too.
RUN apt-get update && apt-get install -y gnupg gnupg2 gnupg1 \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906 \
&& apt-get install -y libgmp-dev --fix-missing \
&& docker-php-ext-install gmp
and if you faced some issue about libreadline8 you can do like bellow.
RUN apt-get install -y libreadline8 --fix-missing
RUN apt-get update && apt-get install -y gnupg gnupg2 gnupg1 --fix-missing
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906
RUN apt-get install -y libgmp-dev --fix-missing
RUN docker-php-ext-install gmp

Docker with wkhtmltopdf is not work correctly

I am trying to use wkhtmltopdf in a container with Docker and Symfony.
The installation is done well, but the result is very different from the reality, so I think some libraries must be missing in the system, but I don't know which one.
I've been checking other questions here and in google, but they don't help.
FROM phpdockerio/php71-fpm:latest
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install cron \
php7.1-mysql \
php-redis \
php7.1-bcmath \
php7.1-gd \
php-imagick \
php7.1-intl \
cron \
python \
xz-utils \
libxrender1 \
libfontconfig1 \
zlib1g \
fontconfig \
libfreetype6 \
libx11-6 \
libxext6 \
wkhtmltopdf
RUN curl --insecure https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer
RUN cd /tmp \
&& curl "https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz" -L -o "wkhtmltopdf.tar.xz" \
&& tar Jxvf wkhtmltopdf.tar.xz \
&& rm wkhtmltopdf.tar.xz \
&& mv wkhtmltox/include/* /usr/local/include/ \
&& mv wkhtmltox/lib/* /usr/local/lib/ \
&& mv wkhtmltox/bin/* /usr/local/bin/ \
&& mv wkhtmltox/share/* /usr/local/share/
RUN apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
CMD php-fpm -F
This is the result in the container(docker)
And this is the result on my machine (without docker), as it should be.
Any idea what might be happening?

Docker - Install PHP 5.2.17 and php-gd

I am migrating an extremely old and legacy system written in PHP. Currently I have made good progress, however, the code makes use of a library called PHPLot where it is dependent on php-gd.
I've done everything ... I've been trying to install this dependence for 3 days. Can you help me?
Here's my Dockerfile:
FROM httpd:2.2
MAINTAINER Marcus Campos <campos.v.marcus#gmail.com>
ENV HTTPD_CONF $HTTPD_PREFIX/conf/httpd.conf
ENV PHP_INI /usr/local/lib/php.ini
ENV HOME /root
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data \
&& sed -i 's/User daemon/User www-data/' $HTTPD_CONF \
&& sed -i 's/Group daemon/Group www-data/' $HTTPD_CONF
WORKDIR $HOME
ADD http://www.geocities.jp/aoba_suzukaze/php-5.2.17.tar.bz2 .
ADD http://www.geocities.jp/aoba_suzukaze/libxml29_compat.patch .
RUN echo 'ServerName localhost:80' >> $HTTPD_CONF
RUN apt-get update && apt install -y --no-install-recommends bzip2 gcc make libxml2-dev libmysqlclient-dev patch autoconf
RUN ln -sf /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/libmysqlclient.so \
&& ln -sf /usr/lib/x86_64-linux-gnu/libmysqlclient.a /usr/lib/libmysqlclient.a
RUN set -x \
&& tar -xf php-5.2.17.tar.bz2 \
&& cd php-5.2.17 \
&& patch -p0 < $HOME/libxml29_compat.patch \
&& ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --with-pdo-mysql --enable-mbstring \
&& make -j"$(nproc)" \
&& make install \
&& cp php.ini-recommended $PHP_INI
RUN echo '<FilesMatch \.php$>' >> $HTTPD_CONF \
&& echo ' SetHandler application/x-httpd-php' >> $HTTPD_CONF \
&& echo '</FilesMatch>' >> $HTTPD_CONF
RUN sed -i 's/"GPCS"/"EGPCS"/' $PHP_INI
RUN pecl install xdebug-2.2.7 \
&& echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"' >> $PHP_INI \
&& echo 'xdebug.remote_enable=On' >> $PHP_INI \
&& echo 'xdebug.remote_connect_back=On' >> $PHP_INI \
&& echo 'xdebug.remote_autostart=On' >> $PHP_INI \
&& echo 'xdebug.idekey="xdebug"' >> $PHP_INI
WORKDIR $HTTPD_PREFIX/htdocs/
UPDATE:
I was able to solve the problem. Here's my code with the solution:
FROM httpd:2.2
MAINTAINER Marcus Campos <campos.v.marcus#gmail.com>
ENV HTTPD_CONF $HTTPD_PREFIX/conf/httpd.conf
ENV PHP_INI /usr/local/lib/php.ini
ENV HOME /root
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data \
&& sed -i 's/User daemon/User www-data/' $HTTPD_CONF \
&& sed -i 's/Group daemon/Group www-data/' $HTTPD_CONF
WORKDIR $HOME
ADD http://www.geocities.jp/aoba_suzukaze/php-5.2.17.tar.bz2 .
ADD http://www.geocities.jp/aoba_suzukaze/libxml29_compat.patch .
RUN echo 'ServerName localhost:80' >> $HTTPD_CONF
RUN apt-get update && apt install -y --no-install-recommends bzip2 gcc make libxml2-dev libmysqlclient-dev patch autoconf libjpeg-dev libpng12-dev
RUN ln -sf /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/libmysqlclient.so \
&& ln -sf /usr/lib/x86_64-linux-gnu/libmysqlclient.a /usr/lib/libmysqlclient.a
RUN set -x \
&& ln -s /usr/lib/x86_64-linux-gnu/libjpeg.a /usr/lib/libjpeg.a \
&& ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/libjpeg.so \
&& ln -s /usr/lib/x86_64-linux-gnu/libpng.a /usr/lib/libpng.a \
&& ln -s /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/libpng.so \
&& tar -xf php-5.2.17.tar.bz2 \
&& cd php-5.2.17 \
&& patch -p0 < $HOME/libxml29_compat.patch \
&& ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --with-pdo-mysql --enable-mbstring \
&& make -j"$(nproc)" \
&& make install \
&& cp php.ini-recommended $PHP_INI
RUN echo '<FilesMatch \.php$>' >> $HTTPD_CONF \
&& echo ' SetHandler application/x-httpd-php' >> $HTTPD_CONF \
&& echo '</FilesMatch>' >> $HTTPD_CONF
RUN sed -i 's/"GPCS"/"EGPCS"/' $PHP_INI
RUN pecl install xdebug-2.2.7 \
&& echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"' >> $PHP_INI \
&& echo 'xdebug.remote_enable=On' >> $PHP_INI \
&& echo 'xdebug.remote_connect_back=On' >> $PHP_INI \
&& echo 'xdebug.remote_autostart=On' >> $PHP_INI \
&& echo 'xdebug.idekey="xdebug"' >> $PHP_INI
WORKDIR $HTTPD_PREFIX/htdocs/
On your ./configure line:
To enable GD-support configure PHP --with-gd[=DIR] , where DIR is the GD base install directory. To use the recommended bundled version of the GD library, use the configure option --with-gd . GD library requires libpng and libjpeg to compile.
http://php.net/manual/en/image.installation.php

Categories