使用官方的Alpine Docker映像将yaml扩展添加到php [英] add yaml extension to php on using official Alpine Docker image

查看:265
本文介绍了使用官方的Alpine Docker映像将yaml扩展添加到php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下官方php Docker映像: https ://github.com/docker-library/php/blob/76a1c5ca161f1ed6aafb2c2d26f83ec17360bc68/7.1/alpine/Dockerfile



现在我需要添加对yaml扩展的支持,即未与php捆绑在一起。
我看到我正在使用的基本映像使用phpize。



我正在尝试这种方法:

 从php:7.1.5-alpine 

#安装并启用对yaml扩展的支持到php
运行apk add --update yaml yaml -dev
运行pecl频道更新pecl.php.net
运行pecl安装yaml-2.0.0&& docker-php-ext-enable yaml

但是我得到这个错误:

 运行:phpize 
配置为:
PHP Api版本:20160303
Zend Module Api No:20160303
Zend Extension Api编号:320160303
找不到自动配置。请检查您的autoconf安装和
$ PHP_AUTOCONF环境变量。然后,重新运行此脚本。

错误:phpize失败
错误:服务php_env生成失败:命令/ bin / sh -c pecl install yaml-2.0.0&& docker-php-ext-enable yaml'返回了一个非零代码:1

什么是最多



我应该使用它作为基础,还是可以添加参数以使所需扩展名可配置?



/ p>

解决方案

Alpine使用apk来安装软件包。编译过程中抱怨缺少 autoconf ,该文件在Alpine的 autoconf 软件包中找到。



建议您运行以下命令:

 运行apk add --no-cache --virtual .build-deps \ 
g ++使autoconf yaml-dev

运行pecl channel-update pecl.php.net
运行pecl install yaml-2.0.0& ;& docker-php-ext-enable yaml

RUN apk del --purge .build-deps

如果需要安装其他非开发库,可以将它们安装在单独的 apk add 命令中。此过程将:


  1. 使用-no-cache 表示您正在使用更新的索引,而不是在本地缓存(因此无需-update 或将pkg保存在缓存中)。 -虚拟意味着您正在为以后可以删除的所有软件包创建虚拟引用(因为它们在编译过程后无用)


  2. 使用pecl和docker-php-ext-enable

  3. 做你的事情
  4. 删除以前的构建部门


如果您仍然遇到缺少的依赖项,则可以看到以下内容: https://pkgs.alpinelinux.org/packages


I'm using this offical php Docker image: https://github.com/docker-library/php/blob/76a1c5ca161f1ed6aafb2c2d26f83ec17360bc68/7.1/alpine/Dockerfile

Now I need to add support for yaml extension, that is not bundled with php. I see the base image I'm using uses phpize.

I'm trying with this approach:

FROM php:7.1.5-alpine

# Install and enable yaml extension support to php
RUN apk add --update yaml yaml-dev
RUN pecl channel-update pecl.php.net  
RUN pecl install yaml-2.0.0 && docker-php-ext-enable yaml

But I get this errors:

running: phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed
ERROR: Service 'php_env' failed to build: The command '/bin/sh -c pecl  install yaml-2.0.0 && docker-php-ext-enable yaml' returned a non-zero code: 1

What is the most idiomatic docker way to use that image and add that support?

Should I use it as base, or is someway possible to add parameters in order to make wanted extension configurable?

解决方案

Alpine uses apk to install packages. The compiling process is complaining about missing autoconf, which is found in Alpine's autoconf package.

I'd suggest you to run these commands:

RUN apk add --no-cache --virtual .build-deps \
    g++ make autoconf yaml-dev

RUN pecl channel-update pecl.php.net
RUN pecl install yaml-2.0.0 && docker-php-ext-enable yaml

RUN apk del --purge .build-deps

If you need to install other non-dev libraries, you can install them in a separate apk add command. This procedure will:

  1. install the build deps, using --no-cache means you're using an updated index and not cached locally (thus no need of --update or to save the pkg in the cache). --virtual means you're creating a virtual reference for all those packages that can later be deleted (because they're useless after the compiling process)

  2. do your stuff with pecl and docker-php-ext-enable

  3. delete the previous build deps

If you still encounter any missing dependency, you can see as reference this: https://pkgs.alpinelinux.org/packages

这篇关于使用官方的Alpine Docker映像将yaml扩展添加到php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆