Imagick Docker Alpine Linux php8.2

q8l4jmvw  于 2023-05-16  发布在  Docker
关注(0)|答案(1)|浏览(260)

我试图在alpine linux上安装imagick for php8.2,但我真的不知道该怎么做。我看到imagick扩展仍在测试中。从我所读到的,我可以通过指定不同的存储库来安装它。但是,当我这样做时,我得到一个错误:php82-common (no such package):。我找不到这个包php82-common是什么。
我的dockerfile如下:

FROM laravelphp/vapor:php82

RUN apk --update add postgresql14-client

# INSTALL COMPOSER
RUN curl -s https://getcomposer.org/installer | php
RUN alias composer='php composer.phar'

# INSTALL PHP EXTENSIONS
RUN apk add php82-pecl-imagick --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing
RUN apk --update add imagemagick imagemagick-dev
RUN docker-php-ext-enable imagick

RUN docker-php-ext-install gd
RUN docker-php-ext-install exif

# Place application in Lambda application directory...
COPY . /var/task
qkf9rpyu

qkf9rpyu1#

找不到php82-pecl-imagick包的原因是它从Alpine的testing存储库升级为community。因此,community仓库应该传递给apk的--repository选项:

RUN apk add php82-pecl-imagick --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community

此外,您还缺少用于安装Imagick PHP扩展的pecl命令:

RUN pecl install imagick

下面是修复后的Dockerfile,它成功构建:

FROM laravelphp/vapor:php82

RUN apk --update add postgresql14-client

# INSTALL COMPOSER
RUN curl -s https://getcomposer.org/installer | php
RUN alias composer='php composer.phar'

# INSTALL PHP EXTENSIONS
RUN apk add php82-pecl-imagick --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community
RUN apk --update add imagemagick imagemagick-dev
RUN pecl install imagick
RUN docker-php-ext-enable imagick

RUN docker-php-ext-install gd
RUN docker-php-ext-install exif

# Place application in Lambda application directory...
COPY . /var/task

作为参考,您可以找到镜像构建输出here

相关问题