gpt4 book ai didi

docker - 如何将 php gd 扩展添加到 Dockerfile

转载 作者:行者123 更新时间:2023-12-04 22:27:32 44 4
gpt4 key购买 nike

尝试使用 alpine 进行部署时出现此错误:

phpoffice/phpspreadsheet 1.2.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.

这是我的 Dockerfile:
FROM php:7.2-alpine

RUN apk update
RUN apk add zlib-dev gd php7-gd
RUN docker-php-ext-install sockets pdo_mysql zip
RUN apk add --no-cache libpng libpng-dev && docker-php-ext-install gd

该错误是 jenkins 运行的输出。我认为它在这里的某个地方失败了......
build:
docker run --rm --tty --user $$(id -u):$$(id -g) \
--volume "$$(pwd)":/app \
--volume "$$(pwd)/ops/jenkins/github.token":/tmp/auth.json \
--volume "$$(pwd)/ops/jenkins/composer_trust_github.com":/root/.ssh/config \
composer install --no-dev
rm -rf ops/docker/app.tar.gz
tar -czvf ops/docker/app.tar.gz -X ops/jenkins/build_excludes .

docker run --rm --tty --user $(id -u):$(id -g) \
--volume "$(pwd)":/app \
--volume "$(pwd)/ops/jenkins/github.token":/tmp/auth.json \
--volume "$(pwd)/ops/jenkins/composer_trust_github.com":/root/.ssh/config \
--volume "$(pwd)/ops/jenkins/php/php.ini":/usr/local/etc/php/php.ini \
composer install --no-dev
[32mLoading composer repositories with package information[39m
[32mInstalling dependencies from lock file[39m
[37;41mYour requirements could not be resolved to an installable set of packages.[39;49m

Problem 1
- Installation request for phpoffice/phpspreadsheet 1.2.1 -> satisfiable by phpoffice/phpspreadsheet[1.2.1].
- phpoffice/phpspreadsheet 1.2.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.

如何正确添加 ext-gd?

更新:更多信息

Jenkins依次调用的Makefile的命令如下:
prepare:
git clone git@github.com:xxx/go-php-sqs-consumer
cd go-php-sqs-consumer && glide install
docker run --rm -v "${PWD}/go-php-sqs-consumer":/go/src/app -w /go/src/app golang:1.8.1-alpine go build -o consumer
mv go-php-sqs-consumer/consumer ops/docker/consumer
rm -rf go-php-sqs-consumer

build:
echo "{\"github-oauth\":{\"github.com\":\"$$(credstash get github.tech-craft.jenkins-eu-west-1)\"}}" > ops/jenkins/github.token
docker run --rm --tty --user $$(id -u):$$(id -g) \
--volume "$$(pwd)":/app \
--volume "$$(pwd)/ops/jenkins/github.token":/tmp/auth.json \
--volume "$$(pwd)/ops/jenkins/composer_trust_github.com":/root/.ssh/config \
composer install --no-dev
rm -rf ops/docker/app.tar.gz
ansible-vault decrypt config.*.json && chmod a+r config.*.json
tar -czvf ops/docker/app.tar.gz -X ops/jenkins/build_excludes .

archive:
aws s3api put-object --bucket craft-build --key "auth-api/${s3_key_version}.tar.gz" --body "ops/docker/app.tar.gz"
aws s3api put-object --bucket craft-build --key "auth-api/current.tar.gz" --body "ops/docker/app.tar.gz"

containerise:
cd ops/docker && docker build --pull --no-cache -t application-exporter-service .

最佳答案

这是我的做法,但在 php图像,而不是 alpine .也许你可以“微调”它以在 Alpine 上工作:

RUN apt-get update && \
apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd

关于docker - 如何将 php gd 扩展添加到 Dockerfile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49998940/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com