我是靠谱客的博主 无语御姐,最近开发中收集的这篇文章主要介绍Dockerfile 文件: docker build制作镜像时,出现pecl not found,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
问题复现:
官方给出的扩展安装地址https://github.com/hyperf/hyperf-docker
RUN apk add --no-cache librdkafka-dev
&& pecl install rdkafka
&& echo "extension=rdkafka.so" > /etc/php7/conf.d/rdkafka.ini
以上代码加入到Dockerfile中,重新build会报错
/bin/sh: pecl: not found
解决方法:
在https://github.com/codecasts/php-alpine/tree/master/scripts/v3.12/php-7.4找到对应的扩展,直接
将目录名加入到Dockerfile中解决
RUN set -ex
&& apk add php7-mongodb
# Default Dockerfile
#
# @link https://www.hyperf.io
# @document https://hyperf.wiki
# @contact group@hyperf.io
# @license https://github.com/hyperf/hyperf/blob/master/LICENSE
FROM hyperf/hyperf:7.4-alpine-v3.11-swoole
LABEL maintainer="Hyperf Developers <group@hyperf.io>" version="1.0" license="MIT" app.name="Hyperf"
##
# ---------- env settings ----------
##
# --build-arg timezone=Asia/Shanghai
ARG timezone
ENV TIMEZONE=${timezone:-"Asia/Shanghai"}
APP_ENV=prod
SCAN_CACHEABLE=(true)
# update
RUN set -ex
# show php version and extensions
&& php -v
&& php -m
&& php --ri swoole
# ---------- some config ----------
&& cd /etc/php7
# - config PHP
&& {
echo "upload_max_filesize=128M";
echo "post_max_size=128M";
echo "memory_limit=1G";
echo "date.timezone=${TIMEZONE}";
} | tee conf.d/99_overrides.ini
# - config timezone
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
&& echo "${TIMEZONE}" > /etc/timezone
# ---------- clear works ----------
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man
&& echo -e "