php:8.0-rc-fpm-alpine: can't stat 'modules/*': No such file or directory
ambroisemaupate opened this issue · 4 comments
When I try to install PHP extension with docker-php-ext-install -j${NPROC} $phpModules
I got following error:
cp: can't stat 'modules/*': No such file or directory
make: *** [Makefile:87: install-modules] Error 1
make: *** Waiting for unfinished jobs....
Dockerfile: https://github.com/ambroisemaupate/docker/blob/master/php80-nginx-alpine/Dockerfile
Build log: https://travis-ci.org/github/ambroisemaupate/docker/jobs/717329430
Many extensions are already compiled into the image, so it's worth checking the output of
php -m
orphp -i
before going through the effort of compiling more.
It is likely because json
and others can't be installed as separate modules and are already installed:
$ docker run -it --rm php:8.0-rc-fpm-alpine php -m
09:39:15 ... $ drr php:8.0-rc-fpm-alpine php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
Fixed up your Dockerfile a bit
FROM php:8.0-rc-fpm-alpine
MAINTAINER Ambroise Maupate <ambroise@rezo-zero.com>
RUN apk --no-cache update \
&& apk --no-cache upgrade \
&& apk add --no-cache --virtual \
.build-deps \
$PHPIZE_DEPS \
gcc \
g++ \
autoconf \
tar \
&& apk add --no-cache \
libxslt-dev \
tidyhtml-dev \
net-snmp-dev \
aspell-dev \
freetds-dev \
openldap-dev \
gettext-dev \
imap-dev \
openssh \
sudo \
make \
shadow \
libmcrypt-dev \
gmp-dev \
openssl \
mariadb-client \
curl \
freetype \
libpng \
libjpeg-turbo \
freetype-dev \
libpng-dev \
libjpeg-turbo-dev \
libwebp-dev \
libzip-dev \
bzip2-dev \
postgresql-dev \
supervisor \
bash \
nginx \
pngquant \
jpegoptim \
zip \
icu-dev \
libxml2-dev \
dcron \
wget \
rsync \
ca-certificates \
oniguruma-dev \
&& phpModules=" \
bcmath \
bz2 \
calendar \
exif \
gd \
gettext \
gmp \
imap \
intl \
ldap \
mysqli \
pcntl \
pdo_dblib \
pdo_mysql \
pdo_pgsql \
pgsql \
pspell \
shmop \
snmp \
soap \
sockets \
sysvmsg \
sysvsem \
sysvshm \
tidy \
xsl \
" \
&& NPROC=$(getconf _NPROCESSORS_ONLN) \
&& docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \
# Install APCU
# @see https://github.com/docker-library/php/issues/1029
&& mkdir -p /usr/src/php/ext/apcu \
&& mkdir -p /usr/src/php/ext/amqp \
&& mkdir -p /usr/src/php/ext/igbinary \
&& mkdir -p /usr/src/php/ext/mongodb \
&& mkdir -p /usr/src/php/ext/redis \
&& curl -fsSL https://pecl.php.net/get/apcu | tar xvz -C "/usr/src/php/ext/apcu" --strip 1 \
&& curl -fsSL https://pecl.php.net/get/amqp | tar xvz -C "/usr/src/php/ext/amqp" --strip 1 \
&& curl -fsSL https://pecl.php.net/get/igbinary | tar xvz -C "/usr/src/php/ext/igbinary" --strip 1 \
&& curl -fsSL https://pecl.php.net/get/mongodb | tar xvz -C "/usr/src/php/ext/mongodb" --strip 1 \
&& curl -fsSL https://pecl.php.net/get/redis | tar xvz -C "/usr/src/php/ext/redis" --strip 1 \
&& docker-php-ext-install -j${NPROC} $phpModules \
&& apk del --no-cache gcc g++ freetype-dev libpng-dev libjpeg-turbo-dev .build-deps
I cut off the lower end because it was erroring on issues like amqp doesn't exist
and igbinary doesn't exist
exif, json, pdo, mbstring apcu, zend opcache, are already loaded so I removed them
Added libxslt-dev
tidyhtml-dev
net-snmp-dev
aspell-dev
freetds-dev
openldap-dev
gettext-dev
imap-dev
$ docker build . -t php:test
Sending build context to Docker daemon 46.81MB
Step 1/3 : FROM php:8.0-rc-fpm-alpine
---> 9cf04f9341c1
Step 2/3 : MAINTAINER Ambroise Maupate <ambroise@rezo-zero.com>
---> Using cache
---> 6a29b25e4beb
Step 3/3 : RUN apk --no-cache update && apk --no-cache upgrade && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS gcc g++ autoconf tar && apk add --no-cache libxslt-dev tidyhtml-dev net-snmp-dev aspell-dev freetds-dev openldap-dev gettext-dev imap-dev openssh sudo make shadow libmcrypt-dev gmp-dev openssl mariadb-client curl freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev libzip-dev bzip2-dev postgresql-dev supervisor bash nginx pngquant jpegoptim zip icu-dev libxml2-dev dcron wget rsync ca-certificates oniguruma-dev && phpModules=" bcmath bz2 calendar exif gd gettext gmp imap intl ldap mysqli pcntl pdo_dblib pdo_mysql pdo_pgsql pgsql pspell shmop snmp soap sockets sysvmsg sysvsem sysvshm tidy xsl " && NPROC=$(getconf _NPROCESSORS_ONLN) && docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp && mkdir -p /usr/src/php/ext/apcu && mkdir -p /usr/src/php/ext/amqp && mkdir -p /usr/src/php/ext/igbinary && mkdir -p /usr/src/php/ext/mongodb && mkdir -p /usr/src/php/ext/redis && curl -fsSL https://pecl.php.net/get/apcu | tar xvz -C "/usr/src/php/ext/apcu" --strip 1 && curl -fsSL https://pecl.php.net/get/amqp | tar xvz -C "/usr/src/php/ext/amqp" --strip 1 && curl -fsSL https://pecl.php.net/get/igbinary | tar xvz -C "/usr/src/php/ext/igbinary" --strip 1 && curl -fsSL https://pecl.php.net/get/mongodb | tar xvz -C "/usr/src/php/ext/mongodb" --strip 1 && curl -fsSL https://pecl.php.net/get/redis | tar xvz -C "/usr/src/php/ext/redis" --strip 1 && docker-php-ext-install -j${NPROC} $phpModules && apk del --no-cache gcc g++ freetype-dev libpng-dev libjpeg-turbo-dev .build-deps
---> Using cache
---> 5bfaafef368a
Successfully built 5bfaafef368a
Successfully tagged php:test
Thanks @yosifkit @wglambert
I managed to clean up Dockerfile and make it pass.
For me, I just removed json from php extension because he is natively installed from php 8