docker compose exec backend.fpm php -r 'print_r(gd_info());'
Warning: PHP Startup: Unable to load dynamic library 'gd.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20220829/gd.so (Error loading shared library libpng16.so.16: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20220829/gd.so)), /usr/local/lib/php/extensions/no-debug-non-zts-20220829/gd.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20220829/gd.so.so: No such file or directory)) in Unknown on line 0
backend.fpm:
build:
context: .
target: fpm_server
image: backend/fpm_server
volumes:
- '.:/opt/apps/src'
networks:
- backend
ARG PHP_EXTS="bcmath ctype fileinfo mbstring pdo pdo_mysql dom pcntl gd"
ARG PHP_PECL_EXTS="redis"
ARG PHP_EXT_DEPS="freetype-dev libjpeg-turbo-dev libwebp-dev libpng-dev"
ARG PHP_EXT_CONF="gd --enable-gd --with-freetype --with-jpeg --with-webp"
# other ...
FROM php:8.2.6-fpm-alpine as fpm_server
ARG PHP_EXTS
ARG PHP_PECL_EXTS
ARG PHP_EXT_DEPS
ARG PHP_EXT_CONF
WORKDIR /opt/apps/src
RUN apk add --virtual build-dependencies --no-cache ${PHPIZE_DEPS} ${PHP_EXT_DEPS} openssl ca-certificates libxml2-dev oniguruma-dev \
&& docker-php-ext-configure ${PHP_EXT_CONF} \
&& docker-php-ext-install -j$(nproc) ${PHP_EXTS} \
&& pecl install ${PHP_PECL_EXTS} \
&& docker-php-ext-enable ${PHP_PECL_EXTS} \
&& apk del build-dependencies
USER www-data
COPY --from=composer_base --chown=www-data /opt/apps/src /opt/apps/src
COPY --from=frontend --chown=www-data /opt/apps/src/public /opt/apps/src/public
--virtual
в команде apk add --virtual build-dependencies
и если в конце удаляются зависимости apk del build-dependencies
, то могут возникать ошибки. # Добавить это
RUN apk add --no-cache ${PHP_EXT_DEPS}
# перед этим
RUN apk add --virtual build-dependencies --no-cache #...