Docker 套接字构建错误和 php-fpm 8.0 'sizeof' 对不完整类型 'struct cmsgcred' 的无效应用
Docker Build Error with Sockets and php-fpm 8.0 invalid application of 'sizeof' to incomplete type 'struct cmsgcred'
我有一个自定义 Docker 构建的 nginx 和 php-fpm,我很确定直到最近它还在工作。我现在在使用 8.0-fpm 时使用下面的 Docker 文件进行构建时出现上述错误,但使用 8.1.1-fpm-bullseye 时却没有,尽管在某些情况下使用 8.1.1 还存在一些其他问题PHP 代码(弃用和警告)。
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"]
错误似乎是在此处抛出的:
#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
任何有关优化构建的建议也将不胜感激。
如果我有一个帐户来存储私有图像,我还有一个关于将构建的图像保存到 Docker Hub 的问题。例如下面是 docker-compose.yml 文件的一个片段。我不太清楚是否可以绕过构建并仅使用我存储在 Docker Hub 帐户中的构建图像。似乎如果我注释掉构建行,那么它将访问 dockerhub 图像来构建容器,但我不清楚 Docker 文件中的其他一些命令是否(即入口点、作曲家安装等)在这种情况下执行。
我的目标是获得我认为“稳定”的图像,然后在 DockerHub 上提供这些图像,而不是每次都必须在新的 machine 上构建图像。另外,一旦我得到一个 运行,mac 上的 M1 芯片可能会出现一些问题。
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"
PHP 8.0.15
和 8.1.2
有一个错误,它会破坏编译 sockets
扩展。
您有两个选择:
- 跳过这个版本。
- Apply a workaround 绕过错误并构建
sockets
扩展。
来源:
我有一个自定义 Docker 构建的 nginx 和 php-fpm,我很确定直到最近它还在工作。我现在在使用 8.0-fpm 时使用下面的 Docker 文件进行构建时出现上述错误,但使用 8.1.1-fpm-bullseye 时却没有,尽管在某些情况下使用 8.1.1 还存在一些其他问题PHP 代码(弃用和警告)。
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"]
错误似乎是在此处抛出的:
#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
任何有关优化构建的建议也将不胜感激。
如果我有一个帐户来存储私有图像,我还有一个关于将构建的图像保存到 Docker Hub 的问题。例如下面是 docker-compose.yml 文件的一个片段。我不太清楚是否可以绕过构建并仅使用我存储在 Docker Hub 帐户中的构建图像。似乎如果我注释掉构建行,那么它将访问 dockerhub 图像来构建容器,但我不清楚 Docker 文件中的其他一些命令是否(即入口点、作曲家安装等)在这种情况下执行。
我的目标是获得我认为“稳定”的图像,然后在 DockerHub 上提供这些图像,而不是每次都必须在新的 machine 上构建图像。另外,一旦我得到一个 运行,mac 上的 M1 芯片可能会出现一些问题。
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"
PHP 8.0.15
和 8.1.2
有一个错误,它会破坏编译 sockets
扩展。
您有两个选择:
- 跳过这个版本。
- Apply a workaround 绕过错误并构建
sockets
扩展。
来源: