I have a custom Docker build of nginx and php-fpm that I am pretty sure was working until recently. I am now getting the error mentioned above during a build using the DockerFile below when using 8.0-fpm, but not with 8.1.1-fpm-bullseye, although there are some other issues with using 8.1.1 in some of the PHP code (deprecations and warnings).
FROM php:8.0-fpm
#FROM php:8.1.1-fpm-bullseye
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies, libssl1.1-dev ?
# Debian GNU/Linux 11 (bullseye), xvfb and xorg are required for wkhtmltopdf, or the xfonts, fontconfig onwards
RUN apt-get update && apt-get install -y \
wget \
openssl \
libssl1.1 \
ca-certificates \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl \
libzip-dev \
dcmtk \
nginx \
supervisor \
libpq-dev \
geoip-database \
libgeoip1 \
fontconfig \
xfonts-75dpi \
xfonts-100dpi \
xfonts-scalable \
xfonts-base \
libxrender1
# adjustments to php.ini base on the production version.
# application/wasm wasm is missing from distro.
COPY php.ini /usr/local/etc/php/php.ini
COPY mime.types /etc/nginx/mime.types
# Install extensions and configure
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-configure zip
RUN docker-php-ext-install pdo_mysql zip exif pcntl gd sockets
# Install Postgre PDO
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
RUN docker-php-ext-install pdo pdo_pgsql pgsql
# php.ini sort of takes care of these, but this is another option.
# RUN sed -E -i -e 's/max_execution_time = 1200/max_execution_time = 120/' /etc/php.ini \
# && sed -E -i -e 's/memory_limit = 128M/memory_limit = 512M/' /etc/php.ini \
# && sed -E -i -e 's/post_max_size = 8M/post_max_size = 64M/' /etc/php.ini \
# && sed -E -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 64M/' /etc/php.ini
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY entrypoint.sh /
ENTRYPOINT ["/bin/bash","/entrypoint.sh"]
The error looks like it gets thrown here:
#36 34.46 cc -I. -I/usr/src/php/ext/sockets -I/usr/src/php/ext/sockets/include -I/usr/src/php/ext/sockets/main -I/usr/src/php/ext/sockets -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -c /usr/src/php/ext/sockets/sendrecvmsg.c -fPIC -DPIC -o .libs/sendrecvmsg.o
#36 34.57 /usr/src/php/ext/sockets/sendrecvmsg.c: In function 'init_ancillary_registry':
#36 34.57 /usr/src/php/ext/sockets/sendrecvmsg.c:128:19: error: invalid application of 'sizeof' to incomplete type 'struct cmsgcred'
#36 34.57 128 | PUT_ENTRY(sizeof(struct cmsgcred), 0, 0, from_zval_write_ucred,
#36 34.57 | ^~~~~~
#36 34.57 /usr/src/php/ext/sockets/sendrecvmsg.c:99:17: note: in definition of macro 'PUT_ENTRY'
#36 34.57 99 | entry.size = sizev; \
#36 34.57 | ^~~~~
#36 34.57 /usr/src/php/ext/sockets/sendrecvmsg.c:129:36: error: 'SCM_CREDS' undeclared (first use in this function)
#36 34.57 129 | to_zval_read_ucred, SOL_SOCKET, SCM_CREDS);
#36 34.57 | ^~~~~~~~~
#36 34.57 /usr/src/php/ext/sockets/sendrecvmsg.c:105:19: note: in definition of macro 'PUT_ENTRY'
#36 34.57 105 | key.cmsg_type = type; \
#36 34.57 | ^~~~
#36 34.57 /usr/src/php/ext/sockets/sendrecvmsg.c:129:36: note: each undeclared identifier is reported only once for each function it appears in
#36 34.57 129 | to_zval_read_ucred, SOL_SOCKET, SCM_CREDS);
#36 34.57 | ^~~~~~~~~
#36 34.57 /usr/src/php/ext/sockets/sendrecvmsg.c:105:19: note: in definition of macro 'PUT_ENTRY'
#36 34.57 105 | key.cmsg_type = type; \
#36 34.57 | ^~~~
#36 34.59 make: *** [Makefile:216: sendrecvmsg.lo] Error 1
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c docker-php-ext-install pdo_mysql zip exif pcntl gd sockets]: exit code: 2
Any suggestions regarding optimizing the build would also be appreciated.
I have another question about saving the built image to Docker Hub if I have an account to store private images. e.g. Below is a snippet from the docker-compose.yml file. It isn't really clear to me if it is possible to bypass the build and just use a built image that I store on my Docker Hub account. It seems like if I comment out the build line, then it will access the dockerhub image to build the container, but it isn't clear to me if some of the other commands in the DockerFile (i.e. entrypoint, composer install, etc.) are executed in that case.
My goal is to arrive at what I consider "stable" images and then make those available on DockerHub instead of having to build the image on a new machine everytime. Also, probably going to run into some issues with an M1 Chip on a mac once I get one.
build: php-fpm-nginx # comment out to use the built image
image: sdscotti/dockerhubimage
depends_on: [mysql_db]
restart: unless-stopped
ports: ["443:443"]
volumes:
- xxx
extra_hosts:
- xxx
environment:
TARGETARCH: "amd64"
CodePudding user response:
PHP 8.0.15
and 8.1.2
has a bug which is breaks compile sockets
extension.
You have a two options:
- Skip this versions.
- Apply a workaround to bypass bug and build
sockets
extenstension.
Source:
CodePudding user response:
I think you need remove sockets
from here:
RUN docker-php-ext-install -j$(nproc) pdo_mysql zip exif pcntl gd sockets
I checked it's work fine.