Can't build up my project on my new laptop (macbook m1). It was built great on my previous machine with Intel.
Here's the part of my Dockerfile
FROM php:7.4-apache
ENV COMPOSER_ALLOW_SUPERUSER 1
ARG GOLANG_VERSION=1.16.5
RUN apt-get update && apt-get install -y \
cron \
curl \
wget \
git \
libfreetype6-dev \
libzip-dev \
libonig-dev \
libxslt-dev \
libicu-dev \
libmcrypt-dev \
libxml2-dev \
libsodium-dev \
libpq-dev \
zlib1g-dev \
libpcre3-dev \
libcurl4-openssl-dev \
libmagickwand-dev --no-install-recommends \
pkg-config \
libssl-dev \
&& a2enmod \
rewrite \
&& pecl install \
imagick \
RUN docker-php-ext-configure \
gd \
pgsql -with-pgsql=/usr/local/pgsql \
exif \
&& docker-php-ext-install \
gd \
mysqli \
pdo \
pdo_pgsql \
pgsql \
sockets \
zip \
mbstring \
xml \
intl \
curl \
exif \
&& docker-php-ext-enable \
imagick \
exif
Here's the part of docker-compose.yaml
version: '3.1'
services:
web:
build: ./docker/web
env_file:
- .env
environment:
- APACHE_RUN_USER=#1000
volumes:
- ${WEB_ROOT_PATH}:/var/www/html/
ports:
- ${WEB_PORT}:80
working_dir: ${WEB_WORKING_DIR}
restart: unless-stopped
Then I do docker-compose up --build -d and after 400 seconds of waiting here's what I got:
#0 106.6 Processing triggers for mailcap (3.69) ...
#0 106.6 Processing triggers for libglib2.0-0:arm64 (2.66.8-1) ...
#0 106.6 No schema files found: doing nothing.
#0 106.6 Processing triggers for libc-bin (2.31-13+deb11u4) ...
#0 106.6 Setting up libcairo2-dev:arm64 (1.16.0-5) ...
#0 106.7 Setting up libgdk-pixbuf-2.0-dev:arm64 (2.42.2+dfsg-1+deb11u1) ...
#0 106.7 Setting up librsvg2-dev:arm64 (2.50.3+dfsg-1) ...
#0 106.7 Setting up libmagickcore-6.q16-dev:arm64 (8:6.9.11.60+dfsg-1.3) ...
#0 106.7 Setting up libmagickwand-6.q16-dev:arm64 (8:6.9.11.60+dfsg-1.3) ...
#0 106.7 Setting up libmagickwand-dev (8:6.9.11.60+dfsg-1.3) ...
#0 106.7 Processing triggers for libgdk-pixbuf-2.0-0:arm64 (2.42.2+dfsg-1+deb11u1) ...
#0 106.8 Enabling module rewrite.
#0 106.8 To activate the new configuration, you need to run:
#0 106.8 service apache2 restart
#0 169.3 No releases available for package "pecl.php.net/imagick"
#0 229.3 No releases available for package "pecl.php.net/RUN"
#0 289.4 No releases available for package "pecl.php.net/gd"
#0 349.5 No releases available for package "pecl.php.net/pgsql"
#0 409.6 No releases available for package "pecl.php.net/exif"
#0 409.6 parsePackageName(): only one version/state delimiter "-" is allowed in "docker-php-ext-configure"
#0 409.6 invalid package name/package file "docker-php-ext-configure"
#0 409.6 Attempting to discover channel "-with-pgsql=/usr/local"...
#0 409.6 Attempting fallback to https instead of http on channel "-with-pgsql=/usr/local"...
#0 409.6 unknown channel "-with-pgsql=/usr/local" in "-with-pgsql=/usr/local/pgsql"
#0 409.6 invalid package name/package file "-with-pgsql=/usr/local/pgsql"
#0 409.6 install failed
------
failed to solve: executor failed running [/bin/sh -c apt-get update && apt-get install -y cron curl wget git libfreetype6-dev libzip-dev libonig-dev libxslt-dev libicu-dev libmcrypt-dev libxml2-dev libsodium-dev libpq-dev zlib1g-dev libpcre3-dev libcurl4-openssl-dev libmagickwand-dev --no-install-recommends pkg-config libssl-dev && a2enmod rewrite && pecl install imagick RUN docker-php-ext-configure gd pgsql -with-pgsql=/usr/local/pgsql exif && docker-php-ext-install gd mysqli pdo pdo_pgsql pgsql sockets zip mbstring xml intl curl exif && docker-php-ext-enable imagick exif]: exit code: 1
I don't really know what's wrong here, I just tried to do the same on my previous machine and it was built fine.
pgsql -with-pgsql=/usr/local/pgsql
i guess it should be
pgsql --with-pgsql=/usr/local/pgsql
So my problem was solved by itself and all containers were built when I turn on VPN.
I don't really know why it works like this but it wasn't be possible to download packages from pecl without using VPN.
Related
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
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
In this code must be an error due to empty arguments in the mysqli_connect function. But browser display different error. As I know mysqli_connect function installed by default. Where is the problem or my mistake? How I can fix it?
Dockerfile
FROM php:fpm
# Update system core
RUN apt update -y && apt upgrade -y
# Start PHP-FPM
CMD ["php-fpm"]
index.php
<?php mysqli_connect('', '', '', '', '', ''); ?>
Error in browser:
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/index.php:3 Stack trace: #0 {main} thrown in /var/www/index.php on line 3
In your Dockerfile for PHP-FPM (I recommend the Alpine version) you have to install MySQLi extension separately
FROM php:7-fpm-alpine
# Update system core
RUN apt update -y && apt upgrade -y
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
# Start PHP-FPM
CMD ["php-fpm"]
In Dockerfile you need add mysqli extension:
FROM php:7.3-fpm
# Update system core
RUN apt update && apt install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev libxml2-dev libcurl4-gnutls-dev
RUN docker-php-ext-install -j$(nproc) mysqli \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
# Start PHP-FPM
CMD ["php-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'.
I try to install GD, because I'm getting the error "Call to undefined function imagecreatefromjpeg()".
When building the image I'm getting the error
E: Unable to locate package libfreetype6-dev
E: Unable to locate package libjpeg62-turbo-dev
E: Unable to locate package libpng12-dev
The command '/bin/sh -c apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev && docker-php-ext-configure gd --enable-gd-native-ttf --with-freetype-dir=/usr/include/freetype2 --with-png-dir=/usr/include --with-jpeg-dir=/usr/include && docker-php-ext-install gd && docker-php-ext-enable gd' returned a non-zero code: 100
My Dockerfile
FROM php:7-fpm
# Install GD
RUN apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng12-dev \
&& docker-php-ext-configure gd \
--enable-gd-native-ttf \
--with-freetype-dir=/usr/include/freetype2 \
--with-png-dir=/usr/include \
--with-jpeg-dir=/usr/include \
&& docker-php-ext-install gd \
&& docker-php-ext-enable gd
What's the right way to install GD?
What about running apt-get update first to update local list of packages? It should always be run before installing:
FROM php:7-fpm
RUN apt-get update && apt-get install --yes libfreetype6-dev ....
According to offical image doc:
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. to install the GD extension you simply have to add these to lines to Dockerfile and get ride of everty things:
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 && sync && \
install-php-extensions gd